function globallink_get_content_attributes_from_xml in GlobalLink Connect for Drupal 7.6
Same name and namespace in other branches
- 7.7 globallink.inc \globallink_get_content_attributes_from_xml()
- 7.5 globallink.inc \globallink_get_content_attributes_from_xml()
Gets content attributes from XML input.
Parameters
string $xml: The raw XML input.
Return value
array Array of content attributes.
1 call to globallink_get_content_attributes_from_xml()
- globallink_get_nid in ./
globallink.inc - Checks for existence of node id object.
File
- ./
globallink.inc, line 507 - Miscellaneous GlobalLink functions for node translations (non-entity).
Code
function globallink_get_content_attributes_from_xml($xml) {
if (is_null($xml) || !is_string($xml) || $xml == '') {
return array();
}
$dom = new DomDocument();
$dom->preserveWhiteSpace = FALSE;
$dom
->loadXML($xml);
$arr = array();
$contents = $dom
->getElementsByTagName('content');
foreach ($contents as $content) {
if (is_null($content->attributes)) {
continue;
}
foreach ($content->attributes as $attr_name => $attr_node) {
switch ($attr_name) {
case 'rid':
$arr['rid'] = $attr_node->value;
break;
case 'nid':
$arr['nid'] = $attr_node->value;
break;
case 'vid':
$arr['vid'] = $attr_node->value;
break;
}
}
}
return $arr;
}