My knowledge of xml and php is somewhat basic but have been able to parse a simple xml document (one level):
<numbers>
<number>1</number>
<number>2</number>
</numbers>
I’m attempting to parse an XML document from a website providing the latest market prices for gold bullion. I think I’m going to need a paid professional but want to give it a shot myself.
the XML file looks like this:
<envelope>
<message type="MARKET_DEPTH_A" version="0.1">
<market>
<pitches>
<pitch
securityClassNarrative="GOLD"
securityId="AUXLN"
considerationCurrency="GBP"
>
<buyPrices>
<price
actionIndicator="B"
quantity="0.153"
limit="23477"
/>
</buyPrices>
<sellPrices>
<price
actionIndicator="S"
quantity="0.058"
limit="23589"
/>
</sellPrices>
</pitch>
</pitches>
</market>
</message>
</envelope>
and simply O have no idea how to access the values within the “headings”. (whatever the term is)
It may sound like I’m asking for someone to do it for me, which I don’t want, but I don’t know what to search for ~ it doesn’t look like a regular xml structure to me.
Using SimpleXML, you can get the attributes using array-notation.
For example, with your XML data, you could have some portion of code that looks like this :
Note : I used
simplexml_load_stringas I had the XML data in a string variable ; but you could also usesimplexml_load_file, depending on your situation/And you’d get the following output :