# XmlReader

**URL:** <https://forum.servoy.com/t/xmlreader/9950>\
**Category:** Classic Servoy\
**Created:** [November 30, 2008, 12:36am UTC](https://forum.servoy.com/t/xmlreader/9950 "2008-11-30T00:36:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chico](https://avatars.discourse-cdn.com/v4/letter/c/b38774/32.png) [@chico](https://forum.servoy.com/u/chico)\
**Post date:** [November 30, 2008, 12:36am UTC](https://forum.servoy.com/t/xmlreader/9950/1 "2008-11-30T00:36:22Z")

</div>

I’m xml parsing challenged… I’m trying to take the following data and parse it down:

```auto
<?xml version="1.0"?>
<RunInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2008-08-08/">
    <requestId>e397a09b-8233-488c-8c17-90ea2088faab</requestId>
    <reservationId>r-2504a54c</reservationId>
    <ownerId>130854919299</ownerId>
    <groupSet>
        <item>
            <groupId>default</groupId>
        </item>
    </groupSet>
    <instancesSet>
        <item>
            <instanceId>i-979321fe</instanceId>
            <imageId>ami-bec226d7</imageId>
            <instanceState>
                0
                <name>pending</name>
            </instanceState>
            <privateDnsName/>
            <dnsName/>
            <reason/>
            <keyName>paygo_keypair</keyName>
            <amiLaunchIndex>0</amiLaunchIndex>
            <instanceType>m1.small</instanceType>
            <launchTime>2008-11-29T06:03:24.000Z</launchTime>
            <placement>
                <availabilityZone>us-east-1a</availabilityZone>
            </placement>
        </item>
    </instancesSet>
</RunInstancesResponse>

```

So I take this string and do this:

```auto
		theResultRaw = poster.getPageData()
			var xmlData = plugins.XmlReader.readXmlDocumentFromString(theResultRaw)
			var theNames = xmlData[0].getChildNodes()
			var theAttributes = xmlData[0].getAttributeNames()
			theResult = null
			for(i = 0; i < theNames.length; i++)
			{
				var currName = theNames[i].getName(); // (theNames[i].getName()).toLowerCase();
				var currValue = theNames[i].getTextValue();
				// set to the field now
				forms[form][currName] = currValue
			}

```

But the output I get is only the requestid, reservationid and ownerid

I assume I’m not getting the other values because they are child nodes of child nodes.

This should be easy… but I’m new to parsing xml.

Any ideas would bring about cheers and applause here.

Chico

---

<div class="post-metadata">

**Author:** ![Alexandru\_Sisu](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@Alexandru\_Sisu](https://forum.servoy.com/u/Alexandru_Sisu)\
**Post date:** [December 2, 2008, 8:51am UTC](https://forum.servoy.com/t/xmlreader/9950/2 "2008-12-02T08:51:37Z")

</div>

Hi Chico,

I run the code, and it went okey.  
Meaning the output for currName was:  
requestId  
reservationId  
ownerId  
groupSet  
instancesSet

and for currValue it was:  
e397a09b-8233-488c-8c17-90ea2088faab  
r-2504a54c  
130854919299

What version of servoy are you using?

Regards,

Alex
