472,951 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,951 software developers and data experts.

How to parse xmlDocument with XPath

Hi All,

I am new to XPath stuff. I want parse XMLDocument with XPath and find
out subset of information. If you look at following xml, for i.e how
can i retrieve subset information such as
'EnrollmentState','SCGProductCollection' or 'EnrollmentEntities'. I
have no idea how to parse following XML

<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:clr="http://schemas.microsoft.com/soap/encoding/clr/1.0"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<a1:EnrollmentState id="ref-1"
xmlns:a1="http://schemas.microsoft.com/clr/nsassem/ABSU.SCG.BusinessObjects/ABSU.SCG%2C%20Version%3D1.1.0.0%2C%20Culture%3Dneu tral%2C%20PublicKeyToken%3D09fbcba969895295">
<currentEnrollmentState
id="ref-3">OrderComplete</currentEnrollmentState>
<sessionId id="ref-4">3lxquwanl1mitt453lzayx45</sessionId>
<productsAvailable href="#ref-5"/>
<databaseId>1460</databaseId>
<referrerId>0</referrerId>
<termsAndConditions id="ref-6">
</termsAndConditions>
<enrollmentException xsi:null="1"/>
<enrollmentEntity href="#ref-7"/>
</a1:EnrollmentState>
<a1:SCGProductCollection id="ref-5"
xmlns:a1="http://schemas.microsoft.com/clr/nsassem/ABSU.SCG.BusinessObjects/ABSU.SCG%2C%20Version%3D1.1.0.0%2C%20Culture%3Dneu tral%2C%20PublicKeyToken%3D09fbcba969895295">
<productList href="#ref-8"/>
</a1:SCGProductCollection>
<a1:EnrollmentEntities id="ref-7"
xmlns:a1="http://schemas.microsoft.com/clr/nsassem/ABSU.SCG.BusinessObjects/ABSU.SCG%2C%20Version%3D1.1.0.0%2C%20Culture%3Dneu tral%2C%20PublicKeyToken%3D09fbcba969895295">
<lastOperationReason id="ref-10">Unknown Enrollment
Reason</lastOperationReason>
<lastOperationStatus id="ref-11">SUCCESS</lastOperationStatus>
<isCallingAsNewService>false</isCallingAsNewService>
<customer href="#ref-12"/>
<campaign xsi:null="1"/>
<appVersion href="#ref-6"/>
<applicationUser xsi:null="1"/>
</a1:EnrollmentEntities>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Nov 12 '05 #1
2 3976
"Blue States" Overload.

"Your" Baseball ticket is valid, IF it
contains all the below in BLUE.

You are an XML Dreamer of the PAST.

==============

Go parse with Xpath using people's data.

without soap or ms in it.

An find out, guy.


I am new to XPath stuff. I want parse XMLDocument with XPath and find
out subset of information. If you look at following xml, for i.e how
can i retrieve subset information such as
'EnrollmentState','SCGProductCollection' or 'EnrollmentEntities'. I
have no idea how to parse following XML

<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:clr="http://schemas.microsoft.com/soap/encoding/clr/1.0"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<a1:EnrollmentState id="ref-1"
xmlns:a1="http://schemas.microsoft.com/clr/nsassem/ABSU.SCG.BusinessObjects/
ABSU.SCG%2C%20Version%3D1.1.0.0%2C%20Culture%3Dneu tral%2C%20PublicKeyToken%3
D09fbcba969895295"> <currentEnrollmentState
id="ref-3">OrderComplete</currentEnrollmentState>
<sessionId id="ref-4">3lxquwanl1mitt453lzayx45</sessionId>
<productsAvailable href="#ref-5"/>
<databaseId>1460</databaseId>
<referrerId>0</referrerId>
<termsAndConditions id="ref-6">
</termsAndConditions>
<enrollmentException xsi:null="1"/>
<enrollmentEntity href="#ref-7"/>
</a1:EnrollmentState>
<a1:SCGProductCollection id="ref-5"
xmlns:a1="http://schemas.microsoft.com/clr/nsassem/ABSU.SCG.BusinessObjects/
ABSU.SCG%2C%20Version%3D1.1.0.0%2C%20Culture%3Dneu tral%2C%20PublicKeyToken%3
D09fbcba969895295"> <productList href="#ref-8"/>
</a1:SCGProductCollection>
<a1:EnrollmentEntities id="ref-7"
xmlns:a1="http://schemas.microsoft.com/clr/nsassem/ABSU.SCG.BusinessObjects/
ABSU.SCG%2C%20Version%3D1.1.0.0%2C%20Culture%3Dneu tral%2C%20PublicKeyToken%3
D09fbcba969895295"> <lastOperationReason id="ref-10">Unknown Enrollment
Reason</lastOperationReason>
<lastOperationStatus id="ref-11">SUCCESS</lastOperationStatus>
<isCallingAsNewService>false</isCallingAsNewService>
<customer href="#ref-12"/>
<campaign xsi:null="1"/>
<appVersion href="#ref-6"/>
<applicationUser xsi:null="1"/>
</a1:EnrollmentEntities>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


Nov 12 '05 #2


John Barring wrote:

I am new to XPath stuff. I want parse XMLDocument with XPath and find
out subset of information. If you look at following xml, for i.e how
can i retrieve subset information such as
'EnrollmentState','SCGProductCollection' or 'EnrollmentEntities'. I
have no idea how to parse following XML

<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:clr="http://schemas.microsoft.com/soap/encoding/clr/1.0"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<a1:EnrollmentState id="ref-1"
xmlns:a1="http://schemas.microsoft.com/clr/nsassem/ABSU.SCG.BusinessObjects/ABSU.SCG%2C%20Version%3D1.1.0.0%2C%20Culture%3Dneu tral%2C%20PublicKeyToken%3D09fbcba969895295">
<currentEnrollmentState
id="ref-3">OrderComplete</currentEnrollmentState>


You need to use an XPath expression like
/SOAP-ENV:Envelope/SOAP-ENV:Body/a1:EnrollmentState
where you need to make sure that the prefixes used (e.g. a1) are bound
to the correct namespace URIs (e.g.
http://schemas.microsoft.com/clr/nsa...fbcba969895295)

If you are using System.Xml.XmlDocument and other nodes then you have
the methods SelectSingleNode and SelectNodes to select nodes with XPath
expressions
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlXmlNodeClassSelectNodesTopic2.asp>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Seong-Tae Jeong | last post by:
for example, xml document is below, It has a default namespace "xmlns='qwer://test'". string xmlText = "<test xmlns='http://test'><clear/><clear/></test>"; I would like to select node list...
10
by: Russell Mangel | last post by:
What would be the best way to parse this XML document? I want to avoid using XMLDocument. I don't know if I should use XMLTextReader, or Xpath classes. There is only one element <MessageStore>...
6
by: David Thielen | last post by:
Hi; I am calling SelectSingleNode("/xml/s:Schema/s:ElementType/@name") where "/xml/s:Schema/s:ElementType/@name is a legit xpath statement (xml is the name of the rootnode) and that xpath...
1
by: John A Grandy | last post by:
I've got an app that has hundreds of medium-sized (100s of elements) XML files on disk (not in db). Right now these are loaded via XMLDocument.Load and searched with XPATH. The performance has...
2
by: Brian | last post by:
Hi all, I have an xml document that can contain 248 nodes with each node containing different fields. There is the possibility that there will be more nodes. Each node can have up to 30...
2
by: C | last post by:
Hi, I have an XML doc as below <WebSRFTemplate Version="1" Type="SERVICE"> <Data> <Field Name="SERVICEStaticRoute2IPnetwork1"><!]></Field> </Data> </WebSRFTemplate>
3
by: Ronald S. Cook | last post by:
I have a string (see below) that I want to parse out the values. As you can see, some are element-based and some are attribute-based. <METADATA version="Format5"><TITLE value="Adrenaline...
6
by: =?Utf-8?B?RGF2aWRN?= | last post by:
Hello, I have an XML file generated from a third party application that I would like to parse. Ideally, I plan on having a windows service setup to scan various folders for XML files and parse the...
1
by: =?Utf-8?B?RGF2aWRHQg==?= | last post by:
OK, so I've created and loaded an XMLDocument object. But how do I go about using it? Specifically, how do I: 1) move to the first node (I assume I start on it when I load the XML?) 2) move to...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.