From: Mangler on 12 Jan 2010 14:32 I am trying to get the data inside of an element from an XML file stream. Today is my first attempt to try this and of course nothing I find on the net is working. Here is what I have: <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <% Dim xmlDoc set xmlDoc = createObject("MSXML2.DOMDocument") xmlDoc.async = False xmlDoc.setProperty "ServerHTTPRequest", true xmlDoc.load("URL_TO_XML_DOCUMENT") response.write xmlDoc.selectNodes("\\EMRSV4.0Response \MerchandiseReturnLabel") %> here is what the XML document looks like: <EMRSV4.0Response> <Zone>5</Zone> <MerchandiseReturnLabel>JVBERi0xLjINCjUgMCBvYmoN=</ MerchandiseReturnLabel> <DeliveryConfirmationNumber>420327139183805213907147133548</ DeliveryConfirmationNumber> <InsuranceCost>1.75</InsuranceCost> <PDUPOBox>240 SPRINGVIEW COMMERCE DR</PDUPOBox> <PDUCity>DEBARY</PDUCity> <PDUState>FL</PDUState> <PDUZip5>32713</PDUZip5> <PDUZip4>4834</PDUZip4> <Postnet>32713483440</Postnet> <CustomerAddress1 /> <CustomerAddress2>6406 IVY LN</CustomerAddress2> <CustomerCity>GREENBELT</CustomerCity> <CustomerState>MD</CustomerState> <CustomerZip5>20770</CustomerZip5> <CustomerZip4>1441</CustomerZip4> <CustomerPostNet>20770144106</CustomerPostNet> </EMRSV4.0Response> I just need to return the value inside the MerchandiseReturnLabel tag. Can anyone help?
From: Martin Honnen on 13 Jan 2010 06:11 Mangler wrote: > I am trying to get the data inside of an element from an XML file > stream. Today is my first attempt to try this and of course nothing I > find on the net is working. Here is what I have: > > <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> > <% > Dim xmlDoc > set xmlDoc = createObject("MSXML2.DOMDocument") It is better to use version indentifier e.g. for MSXML 3 you would use Set xmlDoc = CreateObject("MSXML2.DOMDocument.3.0") as that way you at least know which MSXML version exactly you use. MSXML 3 is available anywhere where IE 6 or later is installed. > > xmlDoc.async = False > xmlDoc.setProperty "ServerHTTPRequest", true > > > xmlDoc.load("URL_TO_XML_DOCUMENT") If you use MSXML 3, as suggested above, then you first should set xmlDoc.setProperty "SelectionLanguage", "XPath" before using selectNodes or selectSingleNode. > response.write xmlDoc.selectNodes("\\EMRSV4.0Response > \MerchandiseReturnLabel") XPath uses the slash "/", not the backslash. And if you want a single node then don't use selectNodes, use selectSingleNode e.g. Response.Write xmlDoc.selectSingleNode("EMRSV4.0Response/MerchandiseReturnLabel").text -- Martin Honnen --- MVP XML http://msmvps.com/blogs/martin_honnen/
From: p byers on 14 Jan 2010 01:31 Martin, In the furtherance of my knowledge base, I used the following script <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <% Dim xmlDoc ''set xmlDoc = createObject("MSXML2.DOMDocument") Set xmlDoc = CreateObject("MSXML2.DOMDocument.3.0") xmlDoc.async = False xmlDoc.setProperty "ServerHTTPRequest", true xmlDoc.setProperty "SelectionLanguage", "XPath" xmlDoc.load("URL_TO_XML_DOCUMENT") ''response.write xmlDoc.selectNodes("\\EMRSV4.0Response\MerchandiseReturnLabel") Response.Write xmlDoc.selectSingleNode("EMRSV4.0Response/MerchandiseReturnLabel").text %> . . . and was rewarded with Error Type: Microsoft VBScript runtime (0x800A01A8) Object required: 'selectSingleNode(...)' /test/getXMLelementTEXT.asp, line 15 Browser Type: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; yie8) Pete (Northolt UK) Mangler wrote: > I am trying to get the data inside of an element from an XML file > stream. Today is my first attempt to try this and of course nothing I > find on the net is working. Here is what I have: > > <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> > <% > Dim xmlDoc > set xmlDoc = createObject("MSXML2.DOMDocument") > > xmlDoc.async = False > xmlDoc.setProperty "ServerHTTPRequest", true > > xmlDoc.load("URL_TO_XML_DOCUMENT") > > response.write xmlDoc.selectNodes("\\EMRSV4.0Response > \MerchandiseReturnLabel") > > %> > > here is what the XML document looks like: > > <EMRSV4.0Response> > <Zone>5</Zone> > <MerchandiseReturnLabel>JVBERi0xLjINCjUgMCBvYmoN=</ > MerchandiseReturnLabel> > <DeliveryConfirmationNumber>420327139183805213907147133548</ > DeliveryConfirmationNumber> > <InsuranceCost>1.75</InsuranceCost> > <PDUPOBox>240 SPRINGVIEW COMMERCE DR</PDUPOBox> > <PDUCity>DEBARY</PDUCity> > <PDUState>FL</PDUState> > <PDUZip5>32713</PDUZip5> > <PDUZip4>4834</PDUZip4> > <Postnet>32713483440</Postnet> > <CustomerAddress1 /> > <CustomerAddress2>6406 IVY LN</CustomerAddress2> > <CustomerCity>GREENBELT</CustomerCity> > <CustomerState>MD</CustomerState> > <CustomerZip5>20770</CustomerZip5> > <CustomerZip4>1441</CustomerZip4> > <CustomerPostNet>20770144106</CustomerPostNet> > </EMRSV4.0Response> > > I just need to return the value inside the MerchandiseReturnLabel > tag. > > Can anyone help?
From: Dan on 14 Jan 2010 05:08 "p byers" <pb(a)sst-ltd.co.uk> wrote in message news:4B4EBA24.124C775E(a)sst-ltd.co.uk... > Martin, > > > In the furtherance of my knowledge base, I used the following script > > > > > > <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> > <% > Dim xmlDoc > ''set xmlDoc = createObject("MSXML2.DOMDocument") > Set xmlDoc = CreateObject("MSXML2.DOMDocument.3.0") > > xmlDoc.async = False > xmlDoc.setProperty "ServerHTTPRequest", true > xmlDoc.setProperty "SelectionLanguage", "XPath" > > > xmlDoc.load("URL_TO_XML_DOCUMENT") This is trying to load the string "URL_TO_XML_DOCUMENT" as XML, which will fail. I think you meant to use xmlDoc.load(URL_TO_XML_DOCUMENT) assuming that URL_TO_XML_DOCUMENT is a variable holding the url. > > ''response.write > xmlDoc.selectNodes("\\EMRSV4.0Response\MerchandiseReturnLabel") > Response.Write > xmlDoc.selectSingleNode("EMRSV4.0Response/MerchandiseReturnLabel").text Where are your slashes denoting the root (\\)? Why are you using / instead of \? response.write xmlDoc.selectSingleNode("\\EMRSV4.0Response\MerchandiseReturnLabel").text > > %> > > > > > > . . . and was rewarded with > > > Error Type: > Microsoft VBScript runtime (0x800A01A8) > Object required: 'selectSingleNode(...)' > /test/getXMLelementTEXT.asp, line 15 The error is due to the node not being found. See the changes as above. Dan > > Browser Type: > Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR > 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; > yie8) > > > > > Pete (Northolt UK) > > > > Mangler wrote: > >> I am trying to get the data inside of an element from an XML file >> stream. Today is my first attempt to try this and of course nothing I >> find on the net is working. Here is what I have: >> >> <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> >> <% >> Dim xmlDoc >> set xmlDoc = createObject("MSXML2.DOMDocument") >> >> xmlDoc.async = False >> xmlDoc.setProperty "ServerHTTPRequest", true >> >> xmlDoc.load("URL_TO_XML_DOCUMENT") >> >> response.write xmlDoc.selectNodes("\\EMRSV4.0Response >> \MerchandiseReturnLabel") >> >> %> >> >> here is what the XML document looks like: >> >> <EMRSV4.0Response> >> <Zone>5</Zone> >> <MerchandiseReturnLabel>JVBERi0xLjINCjUgMCBvYmoN=</ >> MerchandiseReturnLabel> >> <DeliveryConfirmationNumber>420327139183805213907147133548</ >> DeliveryConfirmationNumber> >> <InsuranceCost>1.75</InsuranceCost> >> <PDUPOBox>240 SPRINGVIEW COMMERCE DR</PDUPOBox> >> <PDUCity>DEBARY</PDUCity> >> <PDUState>FL</PDUState> >> <PDUZip5>32713</PDUZip5> >> <PDUZip4>4834</PDUZip4> >> <Postnet>32713483440</Postnet> >> <CustomerAddress1 /> >> <CustomerAddress2>6406 IVY LN</CustomerAddress2> >> <CustomerCity>GREENBELT</CustomerCity> >> <CustomerState>MD</CustomerState> >> <CustomerZip5>20770</CustomerZip5> >> <CustomerZip4>1441</CustomerZip4> >> <CustomerPostNet>20770144106</CustomerPostNet> >> </EMRSV4.0Response> >> >> I just need to return the value inside the MerchandiseReturnLabel >> tag. >> >> Can anyone help? >
From: Dan on 14 Jan 2010 05:11 "p byers" <pb(a)sst-ltd.co.uk> wrote in message news:4B4EBA24.124C775E(a)sst-ltd.co.uk... > xmlDoc.selectSingleNode("EMRSV4.0Response/MerchandiseReturnLabel").text Sorry, in the last reply I stated that you should use \\ and \. That's wrong, it should be xmlDoc.selectSingleNode("//EMRSV4.0Response/MerchandiseReturnLabel").text The // at the start tells the selection handler to base the request off the XML root. It shouldn't be required as you're starting out from there anyway, but it's always worth qualifying it just in case code is added before this later and then you find that you're trying to pull the node from a child node which won't work. However, this probably wasn't the case of the error anyway, the likely reason was not having any XML in xmlDoc because you attempted to load a non-XML string into rather than the XML from the URL. -- Dan
|
Next
|
Last
Pages: 1 2 Prev: Open decoded base64 pdf in browser Next: Classic ASP ASPSessionID cookie HTTPOnly |