If ds.Tables(0).TableName.ToString = "aolxml_ha_adultchild_req" Then
Dim i As Integer
For i = 0 To ds.Tables(0).Rows.Count - 1
MsgBox(ds.Tables(0).Rows(i).Item(7))
Next
End If
คือตอนนี้ผมต้องการรับ tag <childs></childs> อ่ะครับว่าได้ค่าอะไร แต่ผมไม่รู้ว่าคำสั่งอะไร รบกวนหนอ่ยน่ะคัรบ
Private Sub ReadXMLFile()
Dim ds As New DataSet()
Dim strXMLFile = "C:\data.xml"
ds.ReadXml(strXMLFile)
If Not ds Is Nothing Then
Me.DataGridView1.DataSource = ds.Tables(0)
End If
End Sub
Date :
2012-12-11 10:19:12
By :
tee
No. 2
Guest
คือตอนนี้ผมต้องการรับ tag <childs></childs> อ่ะครับว่าได้ค่าอะไร แต่ผมไม่รู้ว่าคำสั่งอะไร รบกวนหนอ่ยน่ะคัรบ
Dim xmlDoc As New XmlDocument()
If System.IO.File.Exists("...\test.xml") Then
xmlDoc.Load("...\test.xml")
Dim elm As XmlElement = xmlDoc.DocumentElement
Dim cNode As XmlNodeList = elm.ChildNodes
For Each node As XmlNode In cNode
If node.Name = "room_details" Then
Console.WriteLine("{0}", node.LastChild.LastChild.Name.ToString())
If node.LastChild.LastChild.Name.ToString() = "childs" Then
MessageBox.Show(node.LastChild.LastChild.InnerText.ToString())
End If
End If
Next
Else
Console.WriteLine("The file {0} could not be located", "...\test.xml")
End If
Code (C#)
XmlDocument xmlDoc = new XmlDocument();
if (System.IO.File.Exists("...\\test.xml"))
{
xmlDoc.Load("...\\test.xml");
XmlElement elm = xmlDoc.DocumentElement;
XmlNodeList cNode = elm.ChildNodes;
foreach (XmlNode node in cNode)
{
if (node.Name == "room_details")
{
Console.WriteLine("{0}", node.LastChild.LastChild.Name.ToString());
if (node.LastChild.LastChild.Name.ToString() == "childs")
{
MessageBox.Show(node.LastChild.LastChild.InnerText.ToString());
}
}
}
}
else
{
Console.WriteLine("The file {0} could not be located", "...\\test.xml");
}