This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Microsoft XML > December 2006 > xpath multiple attributes





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author xpath multiple attributes
kristian

2006-12-06, 7:31 pm

I have a XML file structure that looks like this:
<?xml version="1.0" encoding="iso-8859-1"?>
<list>
<item>
<name>page 1 name</name>
<body>page 1 body</body>
<item>
<name>page 1.1 name</name>
<body>page 1.1 body</body>
</item>
</item>
<item>
<name>page 2 name</name>
<body>page 2 name body</body>
<item>
<name>page 2.1</name>
<body>page 2.1 body</body>
<item>
<name>page 2.1.1</name>
<body>page 2.1.1 body</body>
</item>
</item>
</item>
</list>

how do I get a hold of the item which name is "page 2 name"?

Anthony Jones

2006-12-06, 7:31 pm


"kristian" <kristian@help2hire.com> wrote in message
news:1164871078.595020.107890@l12g2000cwl.googlegroups.com...
> I have a XML file structure that looks like this:
> <?xml version="1.0" encoding="iso-8859-1"?>
> <list>
> <item>
> <name>page 1 name</name>
> <body>page 1 body</body>
> <item>
> <name>page 1.1 name</name>
> <body>page 1.1 body</body>
> </item>
> </item>
> <item>
> <name>page 2 name</name>
> <body>page 2 name body</body>
> <item>
> <name>page 2.1</name>
> <body>page 2.1 body</body>
> <item>
> <name>page 2.1.1</name>
> <body>page 2.1.1 body</body>
> </item>
> </item>
> </item>
> </list>
>
> how do I get a hold of the item which name is "page 2 name"?
>


/list/item[2]/name


kristian

2006-12-06, 7:31 pm


Anthony Jones wrote:
> "kristian" <kristian@help2hire.com> wrote in message
> news:1164871078.595020.107890@l12g2000cwl.googlegroups.com...
>
> /list/item[2]/name


is there any way that I can find it using the names like
"/list/item[page 1 name]/item[page 2 name]

Anthony Jones

2006-12-06, 7:31 pm


"kristian" <kristian@help2hire.com> wrote in message
news:1164888085.059582.227330@h54g2000cwb.googlegroups.com...
>
> Anthony Jones wrote:
>
> is there any way that I can find it using the names like
> "/list/item[page 1 name]/item[page 2 name]
>


/list/item[name="page 1 name"]/item[name="page 2 name"]

You should take the time out to run through this tutorial:-

http://www.w3schools.com/xpath/default.asp




Erwan Amoureux

2006-12-06, 7:31 pm

//item[name="page 2 name"]
--
My english is (very) rusted ,please , don''t hesitate to correct me
Thanks

rédacteur/modérateur XML sur developpez.com


"kristian" wrote:

> I have a XML file structure that looks like this:
> <?xml version="1.0" encoding="iso-8859-1"?>
> <list>
> <item>
> <name>page 1 name</name>
> <body>page 1 body</body>
> <item>
> <name>page 1.1 name</name>
> <body>page 1.1 body</body>
> </item>
> </item>
> <item>
> <name>page 2 name</name>
> <body>page 2 name body</body>
> <item>
> <name>page 2.1</name>
> <body>page 2.1 body</body>
> <item>
> <name>page 2.1.1</name>
> <body>page 2.1.1 body</body>
> </item>
> </item>
> </item>
> </list>
>
> how do I get a hold of the item which name is "page 2 name"?
>
>

kristian

2006-12-06, 7:31 pm




Anthony Jones wrote:
> "kristian" <kristian@help2hire.com> wrote in message
> news:1164888085.059582.227330@h54g2000cwb.googlegroups.com...
>
> /list/item[name="page 1 name"]/item[name="page 2 name"]
>
> You should take the time out to run through this tutorial:-
>
> http://www.w3schools.com/xpath/default.asp


Thanks for the reply

Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews