-1
이 코드는 기존 xml 파일에서 읽은 내용을 레이블에 쓰지 만 작동하지 않으며 어디서 잘못되었는지 알지 못합니다. . 도움을 주시면 감사하겠습니다.xml 판독기가 xml 파일을 읽지 않고 레이블에 표시되지 않습니다.
Dim reader As New XmlTextReader(Server.MapPath("~/ex01/docP.xml"))
'declare variable to record when a <name> element is found'
Dim bName As Boolean = False
'iterate through all of the nodes in the XML document'
While reader.Read()
'look at the node type of each node'
Select Case reader.NodeType
'if node is a <name> element, remember it'
Case XmlNodeType.Element
If reader.Name = "name" Then
bName = True
End If
'if node is text & previous node was <name>, add it to Label'
Case XmlNodeType.Text
If bName Then
lblDisplayXml.Text &= reader.ReadString & "<br/>"
'reset variable for next node'
bName = False
End If
End Select
End While
End Sub
End Class
XML 파일 : 더 < 이름> 요소가 XML에 없다
<?xml version="1.0" standalone="yes"?>
<book_club>
<book>
<isbn>0-13-129014-2</isbn>
<title>JAVA How to Program (6th Ed)</title>
<author>PJ & HM Deitel</author>
<price>£39.99</price>
</book>
<book>
<isbn>0-67-232238-2</isbn>
<title>Teach Yourself UML</title>
<author>J Schmuller</author>
<price>£9.99</price>
</book>
<book>
<isbn>0-27-365575-2</isbn>
<title>Practical Business Systems Development using SSADM</title>
<author>P Weaver, N Lambrou & M Walkley</author>
<price>£34.99</price>
</book>
<book>
<isbn>0-67-232422-9</isbn>
<title>XML Primer Plus</title>
<author>N Chase</author>
<price>£32.99</price>
</book>
<book>
<isbn>0-78-972476-6</isbn>
<title>XML and Java from Scratch</title>
<author>N Chase</author>
<price>£19.99</price>
</book>
<book>
<isbn>1234567890</isbn>
<title>ASP.NET for Dummies</title>
<author>RUA Dummy</author>
<price>free!!</price>
</book>
</book_club>
xml 파일을 표시 할 수 있습니까? 반복 후 lblDisplayXml.Text가 비어있는 것입니까? –
안녕하세요, XML 파일을 게시했습니다. 레이블은 브라우저에서 볼 때 사라집니다. – user1275084
XML에 name이라는 요소가없는 것 같습니다. 'If reader.Name = "name"Then'에서''name "'을''author"''또는''title "'으로 대체하면 코드가 출력물을 생성합니까? – JamieSee