I have a sample XML file as below:
<?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>
<h:title>tutorial</h:title>
<model>
<instance>
<tutorial id="tutorial">
<name/>
<age/>
<gender/>
<photo/>
<date/>
<location/>
<thanks/>
<start/>
<end/>
<today/>
<deviceid/>
<subscriberid/>
<simserial/>
<phonenumber/>
<meta>
<instanceID/>
</meta>
</tutorial>
</instance>
<bind nodeset="/tutorial/name" required="true()" type="string"/>
<bind constraint=". > 0 and . < 120" jr:constraintMsg="That's not a valid age!" nodeset="/tutorial/age" required="true()" type="int"/>
<bind nodeset="/tutorial/gender" type="select1"/>
<bind nodeset="/tutorial/photo" type="binary"/>
<bind nodeset="/tutorial/date" type="date"/>
<bind nodeset="/tutorial/location" type="geopoint"/>
<bind nodeset="/tutorial/thanks" readonly="true()" type="string"/>
<bind jr:preload="timestamp" jr:preloadParams="start" nodeset="/tutorial/start" type="dateTime"/>
<bind jr:preload="timestamp" jr:preloadParams="end" nodeset="/tutorial/end" type="dateTime"/>
<bind jr:preload="date" jr:preloadParams="today" nodeset="/tutorial/today" type="date"/>
<bind jr:preload="property" jr:preloadParams="deviceid" nodeset="/tutorial/deviceid" type="string"/>
<bind jr:preload="property" jr:preloadParams="subscriberid" nodeset="/tutorial/subscriberid" type="string"/>
<bind jr:preload="property" jr:preloadParams="deviceid" nodeset="/tutorial/simserial" type="string"/>
<bind jr:preload="property" jr:preloadParams="phonenumber" nodeset="/tutorial/phonenumber" type="string"/>
<bind calculate="concat('uuid:', uuid())" nodeset="/tutorial/meta/instanceID" readonly="true()" type="string"/>
</model>
</h:head>
<h:body>
<input ref="/tutorial/name">
<label>What's your name?</label>
</input>
<input ref="/tutorial/age">
<label>How old are you?</label>
</input>
<select1 ref="/tutorial/gender">
<label>Gender</label>
<item>
<label>Male</label>
<value>male</value>
</item>
<item>
<label>Female</label>
<value>female</value>
</item>
</select1>
<upload mediatype="image/*" ref="/tutorial/photo">
<label>Please Take a picture</label>
</upload>
<input ref="/tutorial/date">
<label>Date</label>
</input>
<input ref="/tutorial/location">
<label>Where are you?</label>
<hint>You need to be outside for your GPS to work.</hint>
</input>
<input ref="/tutorial/thanks">
<label>Thanks for your time <output value="/tutorial/name"/>!</label>
</input>
</h:body>
</h:html>
Now i want to fill <input ref="/tutorial/name">
with the data coming as a response from the web service? I have a web service which is giving the response correctly. Please help me....
If it is just one value to pick from the response and place in the xml then you are good to go with string functions by picking up the tag index and getting substring as value and doing the same in xml file and replacing. If it is more than one value than you can go with xml parsers, using DOM parser like dom4j http://dom4j.sourceforge.net/. If the response is in json then use Google Gson library http://code.google.com/p/google-gson/. – Omar Jan 22 '13 at 15:31