Hi There, I am quite new to simpleXML and I would like to know how I can access child nodes by index singe I do not have the node name

The XML would look like this:

<?xml version="1.0" encoding="UTF-8"?>
        <Content ItemType="ItemType1">
                    <City Code="CPT"><![CDATA[Cape Town]]>
                    <Item Code="000000000001"><![CDATA[Random Text here]]>
                            <Segmentchild1 Code="H"><![CDATA[XXXXXX]]>
                            **<UNKNOWNNODE Code="CPT"><![CDATA[XXXXXXXX]]>
                            <Segmentchild1 Code="A"><![CDATA[XXXXXX]]>
                            **<UNKNOWNNODE Code="CPT"><![CDATA[XXXXXXXX]]>

How can i access the UNKNOWNNODE nodes value and attributes?

I access the nodes like this:
$transferDetails = $xmlResponse->SubRoot->Content->ItemDetails->children();

4 Years
Discussion Span
Last Post by Mike Askew

Does the unknown node always have the Code="CPT" attribute and is the only node within the <SegmentX> node to contain such an attribute value?

If so you could do something along the lines of search the <SegmentX> child nodes for a node with the matching attribute.

Unfortunately I am a .Net developer so can't deliver on the PHP code front but have toyed with XML enough to try give an insight into logic you could use.

Edited by Mike Askew

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.