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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

parsing xml headache MSXML2.DomDocument.3.0

Status
Not open for further replies.

gavray

Programmer
Jul 17, 2000
65
0
0
GB
Hi,

I'm trying to parse the data identified by xml tags and get this data ready to insert into a database. I tried many combinations and looked at various examples online. I get the error

XML Parsing Error: not well-formed
Location:
Line Number 1, Column 26: <font face="Arial" size=2>

if I response.write xmlhttp.responseText
this appears fine on the browser as xml. I seem to spending too long on a solution, would greatly appreciate some help, thanks

'################### CODE ###################################



<% set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")

xmlhttp.open "GET"," xmlhttp.send ""
Response.ContentType = "text/xml"

xmlfeed=xmlhttp.responseText

' this code takes the raw loads it into an XML Object


Set objXMLDoc = Server.CreateObject("MSXML2.DomDocument.3.0")

objXMLDoc.async = false

objXMLDoc.load(xmlfeed)


Dim objChildNodes, strNode
Set objChildNodes = objXMLDoc.documentElement.childNodes

'And if we then iterate through the child nodes, displaying their node names, you will see that they are the two <State> tags of our XML file.

'Code:
For Each strNode In objChildNodes
document.write(strNode.nodeName & "<br>")
Next

%>

the boho from soho
 
Do you have an example of the file you are trying to parse?

The normal way I would do this is to extract the code and put it in a vbs file. Something like this
Code:
  xmlfeed = "..." ' Whatever your input string is
    
  ' this code takes the raw loads it into an XML Object


  'Set objXMLDoc = Server.CreateObject("MSXML2.DomDocument.3.0")
  Set objXMLDoc = CreateObject("MSXML2.DomDocument.3.0")

  objXMLDoc.async = false
    
  objXMLDoc.load(xmlfeed)


   Dim objChildNodes, strNode
   Set objChildNodes = objXMLDoc.documentElement.childNodes

'And if we then iterate through the child nodes, displaying their node names, you will see that they are the two <State> tags of our XML file.

   For Each strNode In objChildNodes
      'document.write(strNode.nodeName & "<br>")
      wscript.echo strNode.nodeName
   Next

Say you called the file xxx.vbs. Run it using

cscript xxx.vbs
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top