Click to See Complete Forum and Search --> : Simple XML into HTML with XML Attributes


cjbeck71081
04-11-2007, 01:57 PM
I am trying to pass the values of this XML file into an HTML table and i cannot find any information on how to do it.

I understand basic XML and HTML syntaxt on elements, like this sample file

myfile.xml
<?xml version="1.0" encoding="utf-8" ?>
<Test>
<Item>This Item</Item>
<Item2>That Item</Item2>
<Test>

endresult.html
<html>
<body>

<xml id="myfile" src="myfile.xml"></xml>

<table border="1" datasrc="#myfile">

<tr>
<td><span datafld="Item"></span></td>
<td><span datafld="Item2"></span></td>
</tr>

</table>

</body>
</html>


What i dont understand is how to access or use the attributes inside of the elements and send them to an HTML table.


Here is the code and here is an example of what i would like my output to look like.

mycode.xml
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<VINquery Version="1.0.0" Report_Type="EXTENDED" Date="4/3/2007">
<VIN Number="WAULD64B14N024605" Status="SUCCESS">
<Vehicle VINquery_Vehicle_ID="26985" Model_Year="2004" Make="Audi" Model="A6" Trim_Level="2.7T">
<Item Key="VINquery_Vehicle_ID" Value="26985" Unit="" />
<Item Key="Model Year" Value="2004" Unit="" />
<Item Key="Make" Value="Audi" Unit="" />
<Item Key="Model" Value="A6" Unit="" />
</Vehicle>
</VIN>
</VINquery>

endfile.html

<html>
<body>

<xml id="mycode" src="mycode.xml"></xml>

<table border="1" datasrc="#mycode">

<tr>
<td><b>Model Year</b>=<i>2004</i></td>
<td><b>Make</b>=<i>Audi</i</td>
<td><b>Model</b>=<i>A6<i></td>
<td></td>
</tr>

</table>

</body>
</html>
(the red text is the stuff i want to come from the XML file)