0
내부 XML을 사용하여 속성 값 :직선 액세스 내가 아래 XML을
<Team>
<Member Name="Alex" Info="<Details Weight="80" Category="Fighter" LastFight="2014-03-01" />"/>
</Team>
나는 특성을로드 할 수있는 방법을 찾고 싶은 LastFight 스트레이트를 XMLDocuments를 많이 만들지 않고. 지금까지 내가 볼 수 있듯이, 당신은 (XmlDocument
f.e) 다른 XML 추상화 객체에로드 피할 수없는,
Dim storagexml As New XmlDocument
storagexml.LoadXml(<Team><Member Name="Alex" Info="<Details Weight="80" Category="Fighter" LastFight="2014-03-01" />"/></Team>)
Dim tempnodelist As XmlNodeList = storagexml.SelectNodes("Team/Member")
For Each tempnode As XmlNode In tempnodelist
If tempnode.Attributes("Name") IsNot Nothing Then
Dim tempdoc As New XmlDocument
tempdoc.LoadXml(tempnode.Attributes("Info").Value)
Dim tempsel As XmlNode = tempdoc.SelectSingleNode("Info")
If Not tempsel.Attributes("LastFight").Value.Trim() = "" Then
RichTextBox1.AppendText(tempnode.Attributes("Name").Value & " " & tempsel.Attributes("LastFight").Value & vbCrLf)
End If
순간 내 머리에 정상에 상승의 가장 큰 질문은 왜 당신이 속성 안에 포함 된 XML을 HTML로 인코딩해야합니까 XML 파일의? 이것은 속성을 문자열로 선택하는 대신 HTML 인코딩 된 문자를 디코딩하고 XML 문서로로드하는 대신 변경할 수 있습니까? – Adrian
내부에 앰퍼샌드가 포함될 일부 텍스트가 있기 때문에. 그런 것을 막기 위해 모든 실수를 방지합니다. – Chelovek
그리고 앰퍼샌드가 포함될 가능성이있는 텍스트를 인코딩하면됩니다. 전체 XML 문서를 인코딩하고 다른 XML 문서의 텍스트 속성에 배치하는 것은 슬레지 해머를 사용하여 개미를 죽이는 것과 유사합니다. – Adrian