A
aligns
Hi,
I want to read the below xml using XPath queries.
I am getting "object reference is nothing" output, though i think the
code is correct and it should get the object required.
Please help me out.
The XML and Code is below:
XML:
<?xml version="1.0" encoding="utf-8" ?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/
envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<dateSection xmlns="http://schemas.xmlsoap.com/50">
<ns1:dateBody xmlns:ns1="http://schemas.xmlsoap.com/60">
<ns1:dateState>
<ns1:stateCode>OK</ns1:stateCode>
</ns1:dateState>
<ns1:dateAction>
<ns1:action>http://huggisadventure.co.au/</
ns1:action>
</ns1:dateAction>
</ns1:dateBody>
</dateSection>
</soapenv:Body>
</soapenv:Envelope>
CODE:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then
langSettings = New System.Xml.XmlDocument
langNSManager = New
System.Xml.XmlNamespaceManager(langSettings.NameTable)
langSettings.Load("C:\\Inetpub\\wwwroot\\WebTest\\xml\
\test.xml")
langNSManager.AddNamespace("soapenv", "http://
schemas.xmlsoap.org/soap/envelope/")
langNSManager.AddNamespace("ns1", "http://
schemas.xmlsoap.com/60")
lblFName.Text =
langSettings.SelectSingleNode("soapenv:Envelope/soapenv:Body/
dateSection/ns1:dateBody/ns1:dateState/ns1:stateCode",
langNSManager).InnerText
End If
End Sub
I want to read the below xml using XPath queries.
I am getting "object reference is nothing" output, though i think the
code is correct and it should get the object required.
Please help me out.
The XML and Code is below:
XML:
<?xml version="1.0" encoding="utf-8" ?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/
envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<dateSection xmlns="http://schemas.xmlsoap.com/50">
<ns1:dateBody xmlns:ns1="http://schemas.xmlsoap.com/60">
<ns1:dateState>
<ns1:stateCode>OK</ns1:stateCode>
</ns1:dateState>
<ns1:dateAction>
<ns1:action>http://huggisadventure.co.au/</
ns1:action>
</ns1:dateAction>
</ns1:dateBody>
</dateSection>
</soapenv:Body>
</soapenv:Envelope>
CODE:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then
langSettings = New System.Xml.XmlDocument
langNSManager = New
System.Xml.XmlNamespaceManager(langSettings.NameTable)
langSettings.Load("C:\\Inetpub\\wwwroot\\WebTest\\xml\
\test.xml")
langNSManager.AddNamespace("soapenv", "http://
schemas.xmlsoap.org/soap/envelope/")
langNSManager.AddNamespace("ns1", "http://
schemas.xmlsoap.com/60")
lblFName.Text =
langSettings.SelectSingleNode("soapenv:Envelope/soapenv:Body/
dateSection/ns1:dateBody/ns1:dateState/ns1:stateCode",
langNSManager).InnerText
End If
End Sub