Link to home
Start Free TrialLog in
Avatar of jazzIIIlove
jazzIIIloveFlag for Sweden

asked on

simple xml parse with xpath and populate a dropdown list

Hi there;

I have the following xml:
<Envelope>
<Body>
<Aresponse>
<Mys>
<My>
<primerId>3</primerid>
<secondaryId>5</secondaryId>
</My>
<My>
<primerId>4</primerid>
<secondaryId>6</secondaryId>
<Mys>
....

Open in new window


I need to do in XPath of C#.
I used this XPath but failed simply node is not found.

"/Envelope/Body/Aresponse/Mys/My/primerId"

Give a hand?

Regards.
Avatar of Ken Butters
Ken Butters
Flag of United States of America image

Try two slashes to start :

"//Envelope/Body/Aresponse/Mys/My/primerId"
SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jazzIIIlove

ASKER

Hi,

Envelope is the root and my xml content doesn't start with <?xml version='1.0'?>

This is the simplied version of my xml. No way with XPath?

Regards.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
<primerId>3</primerid> was a typo but my xml is a soap message actually which starts with Envelope.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also make sure you use selectNodes, not selectSingleNode,
it seems you can have more than one result node
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks guys. Working now. I felt the spirit of old EE here
Geert. Extremely precise guessing