Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 19th, 2005, 12:16 PM
Authorized User
 
Join Date: Oct 2003
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default brand newbie - picking out values

Hi everyone. I'm brand new to using XML and have a question.

I need to get a value out of an XML document returned from a web service. It looks like what is below. What I need to fish out of it is the value that is in this:

<resultattribute>GETDOCKEY</resultattribute>
<resultvalue>MLITERM#0043009D310000000E#PAYOR,AGEN T,THRDP,ASSIGNE1,ASSIGNE2</resultvalue>

I need to get the GETDOCKEY out to use elsewhere. I'm stuck using Visual Basic 6.0 on this one. Any help offered is greatly appreciated.

Thanks!


<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><getListResponse xmlns="http://presentment.myserver.wherever.com"><getListReturn> <?xml version="1.0" encoding="UTF-8"?>

<results>
<resultrecord>
<resultitem>
<resultattribute>
SRCSYSID</resultattribute>
<resultvalue>
DB2</resultvalue>
</resultitem>
<resultitem>
<resultattribute>
DOCUSYSID</resultattribute>
<resultvalue>
MLITERM</resultvalue>
</resultitem>
<resultitem>
<resultattribute>
ARCKEY</resultattribute>
<resultvalue>
0043009D310000000E</resultvalue>
</resultitem>
<resultitem>
<resultattribute>
POLNUM</resultattribute>
<resultvalue>
205080597</resultvalue>
</resultitem>
<resultitem>
<resultattribute>
POLSFX</resultattribute>
<resultvalue>
FM</resultvalue>
</resultitem>
<resultitem>
<resultattribute>
CYCDT</resultattribute>
<resultvalue>
2005-07-12</resultvalue>
</resultitem>
<resultitem>
<resultattribute>
DOCTYPCD</resultattribute>
<resultvalue>
REMIND LETTER</resultvalue>
</resultitem>
<resultitem>
<resultattribute>
COCD</resultattribute>
<resultvalue>
MLI</resultvalue>
</resultitem>
<resultitem>
<resultattribute>
LOBCD</resultattribute>
<resultvalue>
106</resultvalue>
</resultitem>
<resultitem>
<resultattribute>
PRODTYPCD</resultattribute>
<resultvalue>
</resultvalue>
</resultitem>
<resultitem>
<resultattribute>
CASENUM</resultattribute>
<resultvalue>
</resultvalue>
</resultitem>
<resultitem>
<resultattribute>
SRVAGNTNUM</resultattribute>
<resultvalue>
81W058</resultvalue>
</resultitem>
<resultitem>
<resultattribute>
STDRCPNTID</resultattribute>
<resultvalue>
AGENT</resultvalue>
</resultitem>
<resultitem>
<resultattribute>
GETDOCKEY</resultattribute>
<resultvalue>
MLITERM#0043009D310000000E#PAYOR,AGENT,THRDP,ASSIG NE1,ASSIGNE2 </resultvalue>
</resultitem>
</resultrecord>
<resultrecord>
<resultitem>
<resultattribute>
SRCSYSID</resultattribute>
<resultvalue>
DB2</resultvalue>
</resultitem>
<resultitem>
<resultattribute>
DOCUSYSID</resultattribute>
<resultvalue>
MLITERM</resultvalue>
</resultitem>
<resultitem>
<resultattribute>
ARCKEY</resultattribute>
<resultvalue>
0043009D310000000E</resultvalue>
</resultitem>
<resultitem>
<resultattribute>
POLNUM</resultattribute>
<resultvalue>
205080597</resultvalue>
</resultitem>
<resultitem>
<resultattribute>
POLSFX</resultattribute>
<resultvalue>
FM</resultvalue>
</resultitem>
<resultitem>
<resultattribute>
CYCDT</resultattribute>
<resultvalue>
2005-07-12</resultvalue>
</resultitem>
<resultitem>
<resultattribute>
DOCTYPCD</resultattribute>
<resultvalue>
REMIND LETTER</resultvalue>
</resultitem>
<resultitem>
<resultattribute>
COCD</resultattribute>
<resultvalue>
MLI</resultvalue>
</resultitem>
<resultitem>
<resultattribute>
LOBCD</resultattribute>
<resultvalue>
106</resultvalue>
</resultitem>
<resultitem>
<resultattribute>
PRODTYPCD</resultattribute>
<resultvalue>
</resultvalue>
</resultitem>
<resultitem>
<resultattribute>
CASENUM</resultattribute>
<resultvalue>
</resultvalue>
</resultitem>
<resultitem>
<resultattribute>
SRVAGNTNUM</resultattribute>
<resultvalue>
81W058</resultvalue>
</resultitem>
<resultitem>
<resultattribute>
STDRCPNTID</resultattribute>
<resultvalue>
CUSTOMER</resultvalue>
</resultitem>
<resultitem>
<resultattribute>
GETDOCKEY</resultattribute>
<resultvalue>
MLITERM#0043009D310000000E#PAYOR,AGENT,THRDP,ASSIG NE1,ASSIGNE2 </resultvalue>
</resultitem>
</resultrecord>
</results>
</getListReturn></getListResponse></soapenv:Body></soapenv:Envelope>


"A spirit with a vision is a dream with a mission"
__________________
\"A spirit with a vision is a dream with a mission\"
 
Old August 19th, 2005, 04:25 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

If that really is the result returned then it is invalid as XML because it contains an XML declaration in the middle of the file and so you will not be able to process it with an XML parser and will need to use normal string parsing. If the web service can be repaired to produce well formed XML then you can retrieve the value as follows, assuming you have the XML loaded into an instance of Msxml2.DomDocument40:
Code:
'oDom contains SOAP reply
oDom.setProperty "SelectionNamespaces", "xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:ns=""http://presentment.myserver.wherever.com"""
Dim oElement As IXmlDomElement
Dim sXPath As String
sXPath = "soapenv:Envelope/soapenv:Body/ns:getListResponse/ns:getListReturn/ns:results/ns:resultrecord/ns:resultitem[ns:resultattribute = 'GETDOCKEY']/ns:resultvalue"
Set oElement = oDom.selectSingleNode(sXPath)
MsgBox oElement.text
Beware lines wrapping.

To see more examples download the Xml Core Services Version 4.0 SDK from msdn.com/xml.


--

Joe (Microsoft MVP - XML)
 
Old August 19th, 2005, 05:02 PM
Authorized User
 
Join Date: Oct 2003
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I saw that in there and figured it was OK -- IE displays it -- but I'm probably going to write a RegExp to suck that outta there. Thanks very much for your reply.

"A spirit with a vision is a dream with a mission"





Similar Threads
Thread Thread Starter Forum Replies Last Post
Picking mail from Inbox sanjepau Biztalk 0 July 28th, 2007 08:42 AM
Need help picking a class 38ffems Intro Programming 5 April 29th, 2007 11:14 AM
Brand New Database, No records ken.barrett ASP.NET 2.0 Basics 0 October 20th, 2005 04:38 PM
sorting and picking the first set salhabb XSLT 2 September 27th, 2005 04:13 AM
xpath not picking up first element darrenclump XSLT 7 October 13th, 2003 11:36 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.