Reputation: 21
I have an XML file store on the IIS server. I am attempting to get the value of the <amount>
within the <TotalNetCharge>
tag.
Here is the tag that resides in the file location:
<TotalNetCharge>
<Currency>USD</Currency>
<Amount>92.33</Amount>
</TotalNetCharge>
I've tried using the XML in a variable and also reading it in from a file. Neither works. Here is the code:
Set oXML = Server.CreateObject("MSXML2.DomDocument.4.0")
'oXML.LoadXML(SOAPResponse)
oXML.LoadXML("D:\myfile\XMLReply.xml")
For Each oNode In oXML.SelectNodes("//TotalNetCharge/Amount")
Response.Write "test"
Next
Set oXML = Nothing
Nothing gets written to the screen, so I'm assuming the data is not being loaded because if it were the loop would be entered and "test" written to screen. I also tried loading the commented out portion (SOAPResponse) which I know has data in it because I Response.Write it to the screen. Anyone? 2 days on this nonsense.
Update, here is the replacement code that worked.
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.loadXML(SOAPResponse)
Dim TransactionDetail, CustomerTransactionId
Set NodeList = objXMLDoc.getElementsByTagName("ServiceType")
For Each Node In NodeList
Response.write(Node.text & "<br>")
Next
Set NodeList = objXMLDoc.getElementsByTagName("TotalNetCharge")
For Each Node In NodeList
Response.write(Node.text & "<br>")
Next
Upvotes: 1
Views: 1708