digitaldrew
Well-known member
- Joined
- Nov 10, 2012
- Messages
- 167
- Programming Experience
- Beginner
Hey everyone, I'm trying get the "<reason>" InnerText from the XML below, but have not been having any luck. The XML has multiple namespaces in it...
I've tried this multiple ways...
This gives me no messagebox and an "Object reference not set to an instance of an object." exception..
Same thing with both of the codes above - "Object reference not set to an instance of an object." exceptions and no messageboxes..
Thanks in advance!
VB.NET:
<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns:fury="urn:ietf:params:xml:ns:fury-2.0" xmlns:fury-rgp="urn:ietf:params:xml:ns:fury-rgp-1.0" xmlns:fee="urn:ietf:params:xml:ns:fee-0.11" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:smd="urn:ietf:params:xml:ns:signedMark-1.0" xmlns:mark="urn:ietf:params:xml:ns:mark-1.0" xmlns:host="urn:ietf:params:xml:ns:host-1.0" xmlns:launch="urn:ietf:params:xml:ns:launch-1.0" xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1" xmlns:rgp="urn:ietf:params:xml:ns:rgp-1.0" xmlns:idn="urn:ietf:params:xml:ns:idn-1.0" xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:contact="urn:ietf:params:xml:ns:contact-1.0" xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<response>
<result code="1000">
<msg>Command completed successfully</msg>
<extValue>
<value>
<fury:Code>5614</fury:Code>
</value>
<reason>2023-01-12T06:44:05.551Z</reason>
</extValue>
</result>
<resData>
<domain:chkData>
<domain:cd>
<domain:name avail="false">domain.com</domain:name>
<domain:reason>This is a reason.</domain:reason>
</domain:cd>
</domain:chkData>
</resData>
<trID>
<svTRID>000380328629-0000000002</svTRID>
</trID>
</response>
</epp>
I've tried this multiple ways...
VB.NET:
Dim doc = New Xml.XmlDocument()
doc.LoadXml(requestResponse)
Dim nsm = New Xml.XmlNamespaceManager(doc.NameTable)
nsm.AddNamespace("ds", "http://www.w3.org/2000/09/xmldsig#")
nsm.AddNamespace("fury", "urn:ietf:params:xml:ns:fury-2.0")
nsm.AddNamespace("fury-rgp", "urn:ietf:params:xml:ns:fury-rgp-1.0")
nsm.AddNamespace("fee", "urn:ietf:params:xml:ns:fee-0.11")
nsm.AddNamespace("smd", "urn:ietf:params:xml:ns:signedMark-1.0")
nsm.AddNamespace("mark", "urn:ietf:params:xml:ns:mark-1.0")
nsm.AddNamespace("host", "urn:ietf:params:xml:ns:host-1.0")
nsm.AddNamespace("launch", "urn:ietf:params:xml:ns:launch-1.0")
nsm.AddNamespace("rgp", "urn:ietf:params:xml:ns:rgp-1.0")
nsm.AddNamespace("ns", "urn:ietf:params:xml:ns:epp-1.0")
nsm.AddNamespace("contact", "urn:ietf:params:xml:ns:contact-1.0")
nsm.AddNamespace("domain", "urn:ietf:params:xml:ns:domain-1.0")
nsm.AddNamespace("secDNS", "urn:ietf:params:xml:ns:secDNS-1.1")
nsm.AddNamespace("idn", "urn:ietf:params:xml:ns:idn-1.0")
Dim value = doc.SelectSingleNode("//reason", nsm).InnerText
MsgBox(value.ToString)
This gives me no messagebox and an "Object reference not set to an instance of an object." exception..
VB.NET:
Dim doc = XDocument.Parse(requestResponse)
Dim ns As XNamespace = "urn:ietf:params:xml:ns:epp-1.0"
MsgBox(doc.Element("reason").Value)
MsgBox(doc.Element(ns + "reason").Value)
VB.NET:
Dim doc = XDocument.Parse(requestResponse)
Dim ns As XNamespace = "urn:ietf:params:xml:ns:epp-1.0"
MsgBox(doc.Descendants("reason").Value())
MsgBox(doc.Descendants(ns + "reason").Value())
Same thing with both of the codes above - "Object reference not set to an instance of an object." exceptions and no messageboxes..
Thanks in advance!