Re: [xsl] xpath query

Subject: Re: [xsl] xpath query
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Fri, 18 Jan 2008 23:20:48 +0100
Senthil Nathan wrote:
Hi,
Thanks. And as per xml standards i can't have a tag as <1>.
So, if I have that as attribute,

You cannot. You cannot have, i.e.: <node 1="value" />. You can, however, have <node attr="&lt;1>" />, which is as close as it can get to have "<1>" as attribute (value).


can i use xpath to specifically
select that node.

only if you have a node that is valid XML in the input, of course ;) then yes (you can select about anything in XML with XPath).


ie., with the foll. xml,
<root>
<level1>
    <a id="1">......</a>
    <a id="2">......</a>
</level1>
</root>

Is the following correct, /root/level1/*[@id='1']/* to select all
children of <a id="1">

No. It will select all children of all nodes directly under 'level1' with an id="1" (i.e., if you have <b id="i1"> its children will also be selected). If you want all children of <a id="1">, write:


/root/level1/a[@id="1"]/*

HTH,
Cheers,
-- Abel Braaksma

Current Thread