function atomrdf_custom_copy in Feeds Atom 6
Same name and namespace in other branches
- 7 libraries/atomrdf_parser.inc \atomrdf_custom_copy()
1 call to atomrdf_custom_copy()
- atomrdf_parse in libraries/atomrdf_parser.inc
- Parse AtomRDF format - for example:
File
- libraries/atomrdf_parser.inc, line 330
- Contains the atomrd parsing functions.
Code
function atomrdf_custom_copy($xml) {
$blob = array();
foreach ($xml
->children() as $xml_child) {
$key = $xml_child
->getName();
if ($key == "field") {
$i = 0;
$values = array();
foreach ($xml_child
->children() as $field_instance) {
$values[$i] = array();
foreach ($field_instance
->children() as $column) {
$attributes = $column
->attributes();
if (!empty($attributes['name'])) {
$name = (string) $attributes['name'];
$value = (string) $column;
if (!empty($attributes['serialize'])) {
$value = unserialize($value);
}
$values[$i][$name] = $value;
}
}
$i++;
}
$key = "{$xml_child['name']}";
$blob[$key] = $values;
$blob[$key]['#attributes'] = array(
'type' => (string) $xml_child['type'],
);
}
elseif ($key == "properties") {
foreach ($xml_child
->children() as $property) {
$key = "{$property->getName()}";
$value = "{$property}";
$blob[$key] = $value;
}
}
elseif ($key == 'taxonomy') {
foreach ($xml_child
->children() as $term) {
$values = array();
foreach ($term as $data_type => $value) {
$values[$data_type] = "{$value}";
}
$blob[$key][] = $values;
}
}
else {
$value = "{$xml_child}";
$blob[$key] = $value;
}
}
drupal_alter('feeds_atom_atomrdf_parser', $blob, $xml);
return $blob;
}