Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: How to parse this XML - simple but I couldn't figure out [Thread Next] Re: How to parse this XML - simple but I couldn't figure outTo: NULL Date: 1/8/2007 10:53:00 AM OK. It is in SOAP envelope. I did For-each-node-in-childnodes and I got envelope body with all the node text. I think I can go from there. Thanks for all the help. denoxis wrote: > Hi, > > I tried many variations from different examples with no result. I am > getting 'Object required' when I request Text property of a specific > node. Here is the code: > > > ''''''''''''' This code is in ASP/VBScript'''''''''''''''''' > ' objXMLHTTP.responseText contains the XML document (see the previous > post for the XML doc) > ' and that XML document will be the source for objOutputXMLDoc object > Dim objOutputXMLDoc > Set objOutputXMLDoc = Server.CreateObject("Microsoft.XMLDOM") > objOutputXMLDoc.loadXML objXMLHTTP.responseText > ' > ' Parse the XML document. > ' > Dim Node, snode > > ' This is one of the nodes we want (tried "product/attribute1", > "product/attribute3" with same result) > snode = "/main/product/attribute1" > > ' Print the XML doc to make sure object really has it (it prints, > without line breaks) > response.write "<LI>" & objOutputXMLDoc.xml > > ' Select a single node (whether it is necessary or not, putting > documentElement in between does not change the outcome) > Set Node = objOutputXMLDoc.selectSingleNode(snode) > > ' Does it return Null? (It prints False) > response.write "<LI>IsNull? " & IsNull(Node) > > ' Does it return an object? (It prints True) > response.write "<LI>IsObject? " & IsObject(Node) > > ' Here, we get Run-time error: Object required > response.write "<LI>" & Node.Text > > > > Do you see anything that tells what might be wrong here? > > Thanks, > > Deniz > > Peter Flynn wrote: > > denoxis wrote: > > > Hi, > > > > > > I have a simple XML response coming from a server. I am using > > > Microsoft.XMLDOM object in VB script. For some reason I cannot parse > > > this XML properly. Here is the response: > > > > > > <?xml version="1.0" encoding="UTF-8"?> > > > <main> > > > <email>anEmail</email> > > > <address>anAddress</address> > > > <boolean>Y</boolean> > > > <product> > > > <attribute1>someText</attribute1> > > > <attribute2>someNumber</attribute2> > > > <attribute3>someData</attribute3> > > > <attribute4>moreData</attribute4> > > > </product> > > > <queryDate>someDate</queryDate> > > > </main> > > > > That is well-formed XML, so the response is processable. If the file > > was corrupt, then you would get an error message. > > > > > I tried selectSingleNode("product") method but it returns empty. > > > I also tried selectSingleNode("/main/product") with no avail. > > > > /main/product returns one hit here (using xpathtester). > > What do you get for /main/product/attribute1 > > > > > I just noticed response does not have a proper ending (</xml>) could it > > > be the issue, or there is something else? > > > > There is no such thing. The root element start-tag is <main> and the > > root element end-tag is </main>. There is no such element in this > > document as <xml>, so there is no need for any </xml>. Perhaps you are > > confusing the XML Declaration <?xml...> with element markup (no query). > > > > ///Peter > > -- > > XML FAQ: http://xml.silmaril.ie/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
