Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do I get a field value of this XML return ?

Status
Not open for further replies.

prinand

MIS
Jun 13, 2000
98
GB
I am having a problem processing XML reply string from a web services query

<?xml version="1.0" encoding="UTF-8"?>
<UDSObjectList>
<UDSObject>
<Handle>cnt:CCA48</Handle>
<Attributes>
<Attribute DataType="2009">
<AttrName>id</AttrName>
<AttrValue>CCA48E467FCD5946B3F944778F885C28</AttrValue>
</Attribute>
<Attribute DataType="2002">
<AttrName>combo_name</AttrName>
<AttrValue>DT-NL-Velsen</AttrValue>
</Attribute>
</Attributes>
</UDSObject>
</UDSObjectList>

above is the result of a query that only returned one result(this data is in the Variable XMLString below)

below is the script :

Set objXMLDoc = CreateObject("Microsoft.XMLDOM")

XMLString= USDWebService.doSelect(iSID, sObjectType, "last_name LIKE '%dt_nl_vels%'", 10, arrChangeRequestAttr)

objXMLDoc.async = False
objXMLDoc.load(XMLString)

what I want to do is select the 1st USDobject (in case my query retrieved more than one object) and return the handle value. below is how I tried to do it....

Set NodeList = objXMLDoc.GetElementsByTagName("Handle").Item(0).InnerText

nodelist should contain :
cnt:CCA48

the error I get is Object required : 'objXMLDoc.GetElementsByTagName(...).Item(....)'
 
If you mean XMLString be a "string" literally, do this.
>objXMLDoc.load(XMLString)
[tt]objXMLDoc.load[red]XML[/red](XMLString)[/tt]
 
Thanks a lot. just tried that, and that works.

the complete working code is :

Set objXMLDoc = CreateObject("Microsoft.XMLDOM")

XMLString= USDWebService.doSelect(iSID, sObjectType, "last_name LIKE '%dt_nl_vels%'", 10, arrChangeRequestAttr)

objXMLDoc.async = False
objXMLDoc.loadXML(XMLString)

NodeList = objXMLDoc.GetElementsByTagName("Handle").Item(0).Text
msgbox(nodelist)


I did not realized the code :
objXMLDoc.load(XMLString) was for loading a text file.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top