0

please see XML file below which I am trying to display on a web page

<?xml version="1.0" encoding="utf-8" ?> <Quotation> <QuotationLines> <Line> <ItemID>Item ID 1</ItemID> <Description> <TextLine ID="1">Text Line 1 Item ID 1</TextLine> <TextLine ID="2">Text Line 2 Item ID 1</TextLine> <TextLine ID="3">Text Line 3 Item ID 1</TextLine> </Description> </Line> <Line> <ItemID>Item ID 2</ItemID> <Description> <TextLine ID="1">Text Line 1 Item ID 2</TextLine> <TextLine ID="2">Text Line 2 Item ID 2</TextLine> </Description> </Line> </QuotationLines> </Quotation> 

I want it to show as follows as I need to identify each entry to eventually save into a database:

Item ID 1
Text Line 1 Item ID 1
Text Line 2 Item ID 1
Text Line 3 Item ID 1
Item ID 2
Text Line 1 Item ID 2
Text Line 1 Item ID 2

I have worked out how to show the itemid but cannot show just the relevant textlines to that item id.

My code is currently as follows:

<%@ Page Language="vb" %> <%@ Import Namespace="System.Xml" %> <script runat="server" Language="VB"> Sub page_load() Dim objxml As New XmlDocument() objxml.load (Server.MapPath("test1.xml")) Dim nodeList As XmlNodeList = objxml.SelectNodes("/Quotation/QuotationLines/Line") For Each node As XmlNode In nodeList response.Write(node("ItemID").InnerText &"<br>") Next end sub </script> 

Ive spent 2 days so far trying to get this to work so any help would be greatly received. I am not that knowledgeable with asp.net as I still use classic asp.

Many Thanks Kevin

1 Answer 1

1

you just need a second loop:

For Each node As XmlNode In nodeList Response.Write(node("ItemID").InnerText & "<br>") For Each nodeDesc As XmlNode In node("Description").ChildNodes Response.Write(nodeDesc.InnerText & "<br />") Next Next 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.