Re: [xml] results from xpath
- From: "Christopher R. Maden" <crism maden org>
- To: Nicolas ANTONIAZZI <the bestel free fr>
- Cc: xml gnome org
- Subject: Re: [xml] results from xpath
- Date: Mon, 10 May 2004 02:53:19 -0700
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
At 02:36 10/5/04, Nicolas ANTONIAZZI wrote:
I'm using libxml for a project and I'm very impressed by the quantity of
functionnality that it offers. But I have few questions about the XPath
implementation.
xml example :
<a id="1">
<b id="2">
<c id="3">
<d id="6"/>
</c>
</b>
<b id="4">
<c id="5"/>
</b>
</a>
I would like to get the following xml portion :
<b id="2">
<c id="3">
</c>
</b>
The key distinction which I think you are missing is this: the B2 element
is its start-tag, its end-tag, *and all its content*.
So you don't want the B2 node and the C3 node, but not the others; you want
a completely new tree with many similarities.
Identifying the nodes that you want to mimic (I won't say "copy") is easy
enough:
//b[ id='2'] | //c[ id='3']
or even
id('2') | id('3')
if you have the appropriate DTD or schema information available. But now,
you don't *copy* those nodes - you retrieve information from them and
output it. xmlElemDump(), as you've discovered, will give you the entire
element - not just its start- and end-tags. Instead, write new elements
that share information from the old ones. (Sorry for no example - I'm more
familiar with the Perl XML::LibXML interface than the direct C API.)
~Chris
- --
Christopher R. Maden, Principal Consultant, crism consulting
XML-SGML-HTML-DTDs-schemas-XSL-DSSSL-conversion-training-ebooks-B2B
<URL: http://crism.maden.org/consulting/ >
PGP Fingerprint: BBA6 4085 DED0 E176 D6D4 5DFC AC52 F825 AFEC 58DA
-----BEGIN PGP SIGNATURE-----
Version: PGP Personal Privacy 6.5.8
iQA/AwUBQJ9RD6xS+CWv7FjaEQJpbQCeJ5q67MFhYxe1dBw2qlCkNczjt+QAniYZ
kkZPZ7VTLdqYL9Suek4PVXG7
=432Y
-----END PGP SIGNATURE-----
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]