I have the following XML:
<mobapp>
<form>
<input type="text" name="target" id="target" value="" maxlength="8" required="true" pattern="[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]"/>
<label for="target"> Phone number</label>
<input type="number" name="amount" id="amount" min="0" maxlength="16" required="true"/>
<label for="amount"> Amount to load:</label>
</form>
</<mobapp>
When I use simplexml_load_string($theXML) I get the following:
object(SimpleXMLElement)#150 (3) {
["input"]=>
array(2) {
[0]=>
object(SimpleXMLElement)#146 (1) {
["@attributes"]=>
...
}
[1]=>
object(SimpleXMLElement)#146 (1) {
["@attributes"]=>
...
}
}
["label"]=>
array(2) {
[0]=> ...
[1]=> ...
}
( I removed all the attributes to make it simpler to understand)
So I get an array of 2 "input" and an array of 2 "label", but I don't know the order in which they were in the XML.
Is there a way to get that order?
No comments:
Post a Comment