if my XML file is
First, I want "New Year Day" which is in the Day tag. I can use the following instructions to get it.
[VB.Net]
If Not (xdoc.SelectSingleNode("/Year/Month/Day") Is Nothing) Then
Session("DATE") = xdoc.SelectSingleNode("/Year/Month/Day").InnerXml
End If
[C#.Net]
if (xdoc.SelectSingleNode("/Year/Month/Day") != null)
{
DATE = xdoc.SelectSingleNode("/Year/Month/Day").InnerXml;
}
Second, I want "123" which is the value of the attribute Level inside Day's tag. I can use this instructions to get it.
[VB.Net]
If Not (xdoc.SelectSingleNode("/Year/Month/Day/@Level") Is Nothing) Then
Session("DATE_Level") = xdoc.SelectSingleNode("/Year/Month/Day/@Level").InnerXml
End If
[C#.Net]
if (xdoc.SelectSingleNode("/Year/Month/Day/@Level") != null)
{
DATE_Level = xdoc.SelectSingleNode("/Year/Month/Day/@Level").InnerXml;
}
No comments:
Post a Comment