开发者

Javascript And Xpath

I am using plain old school Javascript - So no jQuery responses please!.

I have loaded in an xml document which kind of looks like this

<node>
     <child tags='Foo,Bar'>
          ------ GrandChild Nodes Here
     </child>
     <child tags='Nuts,Bolts'>
          ------ GrandChild Nodes Here
     </child>
      <child tags='Bacon,Eggs'>
          ------ GrandChi开发者_运维知识库ld Nodes Here
     </child>
</node>

What I need to know is if I wanted to get all the children of a node that had been tagged in Foo for example how what I do this using xPath.

Cheers

Steve


Use this XPath 1.0 expression:

/node/child[
   contains(
      concat(',',@tags,','),
      ',Foo,'
   )
]/node()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜