タグ: VB.net XML DOM

文字列をXMLとして読み込む

Dim contents As String =""
      contents &= "<?xml version=""1.0"" encoding=""UTF-8""?>"
      contents &= "<data>"
      contents &=   "<Writer sex=""men="">鈴木一郎"
      contents &=     "<book>XML入門</book>"
      contents &=     "<price>1200</price>"
      contents &=     "<Sales>"
      contents &=       "<store code=""001="">100</store>"
      contents &=       "<store code=""002="">150</store>"
      contents &=       "<store code=""003="">NoHand</store>"
      contents &=       "<store code=""004="">300</store>"
      contents &=     "</Sales>"
      contents &=   "</Writer>"
      contents &= "</data>"
      Dim doc As New XmlDocument
      Dim item As XmlElement
      doc.LoadXml(contents)

普通に文字列でXMLを書き込んで、それをLoadXML関数で読み込ませるだけです。