Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries [Thread Prev] >Thread Next - Re: reading XML elements with asp Help: reading XML elements with aspTo: NULL Date: 7/2/2004 3:21:00 PM Hi!
I need to fill the database with selected elements from XML, but cant get
them apart.
items.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="items.xsd">
<item>
<class>2</class>
<type>0</type>
<code>0101002</code>
</item>
<item>
<class>3</class>
<type>0</type>
<code>0102008</code>
</item>
<item>
<class>4</class>
<type>0</type>
<code>0101018</code>
</item>
...
</dataroot>
ASP file:
<%
Dim sourceFile, source, rootElement, HTMLCode
'define xml file
sourceFile = Server.MapPath("items.xml")
' Create an instance of the XML parser and load the XML into the DOM
Set source = Server.CreateObject("Microsoft.XMLDOM")
source.async = false
source.load sourceFile
Set rootElement = source.documentElement
' list them out
For i = 0 To (rootElement.childNodes.length -1)
Response.Write(rootElement.childNodes(i).text & "<br>")
' the misty part here
Next
The question: how to get elements by name into variable, say just <type> and
<code>, getElementsByTagName("ntype").item(0).text or???
Thnx
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
