In my PHP application i’m using xforms and i need to parse the xml and i would like to access the id of node from xml. I tried normal xml for access id of node and its work fine. But when i tried that approach in xfrom xml, i cant access the id of node. This is the code i tried. In this i need the id of node test_geopoint. Here the node name will changed for each xml forms, so i prefered to access the id of node next to <instance>. How can access the id of that node?
thanks.
<?php
$xmlstr = <<<XML
<?xml version="1.0"?>
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:jr="http://openrosa.org/javarosa" xmlns:orx="http://openrosa.org/xforms/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<h:head>
<model>
<instance>
<test_geopoint id="test_geopoint">
<name/>
<geopoint/>
<meta>
<instanceID/>
</meta>
</test_geopoint>
</instance>
<bind nodeset="/test_geopoint/name" type="string"/>
<bind nodeset="/test_geopoint/geopoint" type="geopoint"/>
<bind calculate="concat('uuid:', uuid())" nodeset="/test_geopoint/meta/instanceID" readonly="true()" type="string"/>
</model>
</h:head>
<h:body>
<input ref="/test_geopoint/name">
<label>What is the name of this store?</label>
</input>
<input ref="/test_geopoint/geopoint">
<label>Collect the GPS coordinates of this store.</label>
<hint>GPS coordinates can only be collected when outside.</hint>
</input>
</h:body>
</h:html>
XML;
$movies = new SimpleXMLElement($xmlstr);
//echo $movies->idList->ids['id'];
echo $movies->model->instance->children()[0]['id'];
?>