how to get a node by its name without using xpath?

53 views
Skip to first unread message

Gleki Arxokuna

unread,
Sep 23, 2014, 8:28:11 AM9/23/14
to libx...@googlegroups.com
if let's say i have
<one someattr="attribute">
  <two>text<two>
  <two>more text<two>
</one>

I can specify the name in .attr("someattr") e.g. to get its value but 
how do i return the array of "two" nodes without using xpath?

Marco Rogers

unread,
Sep 23, 2014, 12:47:56 PM9/23/14
to libx...@googlegroups.com

There's no API for that. You could do it yourself. The childNodes() method will return an array of immediate children. But it would include text and comment nodes. You would just filter those out.

I'm curious why you can't use xpath though (or don't want to).

--
You received this message because you are subscribed to the Google Groups "libxmljs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to libxmljs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages