You have not mentioned the framework version, so I'll illustrate the
pre and the post .NET 3.x method :

VB 7.0 - 8.0
---
doc.LoadXml(xmldata)

Dim mgr As New XmlNamespaceManager(doc.NameTable)
mgr.AddNamespace("fin", "http://www.Fin23.com/ay";)

'Get the *first* PNRef node in the document.
Dim pnRef As XmlNode = doc.SelectSingleNode("/fin:XMLResponse/
fin:ResponseData/fin:TransactionResults/fin:TransactionResult/
fin:PNRef", mgr)
Dim pnRefText As String = pnRef.InnerText
---

VB 9.0
---
Imports <xmlns:fin="http://www.Fin23.com/ay";>
...

Dim xe As XElement = XElement.Parse(xmlData)

'Get the *first* PNRef node in the document.
Dim x = xe...<fin:PNRef> _
 .Select(Function(pnr) pnr.Value) _
 .First()
---


On Sep 25, 7:47 pm, Pat 2345 <[email protected]> wrote:
> Heres my current code. How would I get the text of the element PNREF?
> I want this value "AAA23459"
>
> this line of code returns nothing to me.  Whats wrong with it.
>  s = doc.SelectSingleNode("/http://www.Fin.com/ay/XMLResponse/
> ResponseData/TransactionResults/TransactionResult/PNRef").InnerText
>
> xmldata = "<XMLResponse xmlns=""http://www.Fin23.com/
> ay""><ResponseData><Vendor>FIN</Vendor><Partner>FINl</
> Partner><TransactionResults><TransactionResult><Result>54</
> Result><IAVSResult>N</IAVSResult><AVSResult><StreetMatch>Match</
> StreetMatch><ZipMatch>Match</ZipMatch></AVSResult><Message>Approved</
> Message><PNRef>AAA23459</PNRef><AuthCode>2342</AuthCode></
> TransactionResult></TransactionResults></ResponseData></XMLResponse>"
>
>   Dim s As String
>             'Load the XML so that we can parse it
>             doc.LoadXml(xmldata)
>
>             Root = doc.DocumentElement
>    'I tried adding this but it didnt help
> ''Dim finMgr As New XmlNamespaceManager(doc.NameTable)
> ''finMgr.AddNamespace("fin", "http://www.Fin23.com/ay";)
>
>             s = doc.SelectSingleNode("/http://www.Fin23.com/ay/
> XMLResponse/ResponseData/TransactionResults/TransactionResult/
> PNRef").InnerText

Reply via email to