In a previous question I asked how to extract values from a XML file and put them into an array.
PHP xmlreader - values to array question
When using simpleXML, I was unable to read the XML file without errors being returned. I can only assume the XML file contains some bad characters because the file was successfully read with PHP XMLreader with the encoding set to ISO-8859-1.
Ideally I'd like to use simpleXML because looping seems simpler, but XMLreader seems to work.
- Is there a way to set encoding of an XML file for simpleXML?
2. If using XMLreader, how can you revise the code from my previous question add values to array only when a particular value in an element is found?
Example: Current code from previous question grabs all id and username.
How do you get id and username only when [ title ] = value
<!-- XML File -->
<?xml version="1.0" encoding="UTF-8"?>
<working version="2.0">
<group name="test">
<userdata>
<title>data</title>
<id>data</id>
<username>data</username>
</userdata>
</group>
</working>