Hi,
I have created an XML field with name 'field_xml'.

Now I want to give this fields data to my PHP code, so instead of

$my_xml = simplexml_load_file('my_xml.xml');

I want to do something like

$my_xml = xml_field_xml($field_xml);

But how do I do it to work? The PHP code is in the same node as the xml_field.

Any help?

Comments

alxp’s picture

You can pass the node to xml_field_xml if there is only one xml field and it will find it:

$xml = xml_field_xml($node);
aklump’s picture

To add to what alxp wrote in #1, you can specify the fieldname like this; which is something you have to do if you have more than one xml field on the node (or entity):

$my_xml = xml_field_xml($node->field_xml);
aklump’s picture

Issue summary: View changes
Status: Active » Closed (fixed)