Re: [xml] How to select a node based on attribute values?

On Tue, Nov 28, 2006 at 09:35:38PM -0500, John Dennis wrote:
no need to iterate, just create an xpath expression which specifies id=2

  Well libxml2 XPath implementation will iterate for you more precisely.

off the top of my head the expression would be "/plc[ id="2"]"

just google xpath syntax or xpath examples, you'll turn up a ton

libxml2 xpath example C code here:

The xpath spec has examples too:

If you're comfortable with python or another scripting language you can
construct a simple test program to exercise your xpath syntax in about 5

  You can test that even faster using xmllint --shell test.xml
and using the xpath command directly there


Red Hat Virtualization group
Daniel Veillard      | virtualization library
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]