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 with ASP?

Status
Not open for further replies.

NeoTurtle

Programmer
Aug 25, 2000
38
0
0
US
I've tried looking up info and can't really seem to get a grasp on how XML works... can someone show me how to parse this into a table?

-----------------------------
<character name=&quot;Alexianna Summerbreeze&quot; id=&quot;322413&quot; laston=&quot;2_Weeks&quot;>
<race>Saracen</race>
<class>Infiltrator</class>
<level>50</level>
<guildrank>4</guildrank>
<totalrp>13284</totalrp>
<lastweekrp>1451</lastweekrp>
<totaldeaths>89</totaldeaths>
<lastweekdeaths>5</lastweekdeaths>
<anon>True</anon>
</character>

-----------------------
<html>
<head>

<script type=&quot;text/javascript&quot; for=&quot;window&quot; event=&quot;onload&quot;>
var xmlDoc = new ActiveXObject(&quot;Microsoft.XMLDOM&quot;);
xmlDoc.async=&quot;false&quot;;
xmlDoc.load(&quot;data/1552.xml&quot;);

nodes = xmlDoc.documentElement.childNodes;

race.innerText = xmlDoc.getElementsByTagName(&quot;race&quot;).item(0).text
//class.innerText = xmlDoc.getElementsByTagName(&quot;class&quot;).item(0).text
level.innerText = xmlDoc.getElementsByTagName(&quot;level&quot;).item(0).text
guildrank.innerText = xmlDoc.getElementsByTagName(&quot;guildrank&quot;).item(0).text
totalrp.innerText = xmlDoc.getElementsByTagName(&quot;totalrp&quot;).item(0).text
lastweekrp.innerText = xmlDoc.getElementsByTagName(&quot;lastweekrp&quot;).item(0).text
totaldeaths.innerText = xmlDoc.getElementsByTagName(&quot;totaldeaths&quot;).item(0).text
anon.innerText = xmlDoc.getElementsByTagName(&quot;anon&quot;).item(0).text
</script>

<title>DR</title>
</head>

<body>
<TABLE BORDER=&quot;1&quot;>
<TR>
<TD><span id=&quot;race&quot;></span></TD>
<TD><span id=&quot;class&quot;></span></TD>
<TD><span id=&quot;level&quot;></span></TD>
<TD><span id=&quot;guildrank&quot;></span></TD>
<TD><span id=&quot;totalrp&quot;></span></TD>
<TD><span id=&quot;lastweekrp&quot;></span></TD>
<TD><span id=&quot;totaldeaths&quot;></span></TD>
<TD><span id=&quot;anon&quot;></span></TD>
</TR>
</TABLE>


</body>
</html>
--------------------------------------


Thanks in advance
 
In general you do a transform and then set only a single element.innerHTML to the result of the transform.

There are all sorts of examples at
Also check the sites that are in the &quot;Partners&quot; box at the bottom of the left column of this web site.

-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top