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();

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.