Re: [xml] How to select a node based on attribute values?
- From: Daniel Veillard <veillard redhat com>
- To: John Dennis <jdennis redhat com>
- Cc: xml gnome org
- Subject: Re: [xml] How to select a node based on attribute values?
- Date: Wed, 29 Nov 2006 04:04:47 -0500
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:
http://xmlsoft.org/examples/index.html#XPath
The xpath spec has examples too: http://www.w3.org/TR/xpath
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
minutes.
You can test that even faster using xmllint --shell test.xml
and using the xpath command directly there
Daniel
--
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard | virtualization library http://libvirt.org/
veillard redhat com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]