Re: [xml] find out wether a node is a leaf or contains other elements
- From: Daniel Veillard <veillard redhat com>
- To: klemens letulé <klemens_letule gmx de>
- Cc: xml gnome org
- Subject: Re: [xml] find out wether a node is a leaf or contains other elements
- Date: Tue, 7 Jun 2005 05:58:08 -0400
On Tue, Jun 07, 2005 at 11:40:15AM +0200, "klemens letulé" wrote:
I just started to use libxml and am already stuck. The question is more
or
less in the subject. I want to restrict the deletion of nodes who have
no
child elements.
Have you read the docs ?
http://xmlsoft.org/tree.html
No child element may mean various things, your question is ambiguous.
Node->children == NULL might be the test you want ... or not.
Daniel
Yes, i read the docs... maybe it was too much input in a short time!
Take your time and don't rush. It's like asking questions on a nuclear
physic mailing list without having taken the time to read and digest
the basic science around it.
I try to make it more clear what i want. As an element i mean now an
element as in the DTD.
<!ELEMENT fw-input-rule (action, protocol, from-ip, from-port, to-ip,
to-port, log)>
<!ELEMENT action (#PCDATA)>
<!ELEMENT protocol (#PCDATA)>
<!ELEMENT from-ip (#PCDATA)>
.
.
.
So it should be possible to delete a "fw-input-rule node" but not an
"action node".
Is there an easy way to distinguish between elements who have other "child
elements" and elements who are just a leaf?
Your questions are confusing, you mix content model and actual tree.
I can't answer your question it's too undefined. Where are those DTD
declarations ? External DTD subset are not loaded by default. The
content field of the nodes may be usable or not. And your question is
not precise enough to answer
<fw-input-rule><from-ip/><from-port/><to-ip/></fw-input-rule>
<fw-input-rule/>
have different model, I can't tell what you're considering.
Did you try xmllint --debug on some of those tree to get an idea of
what the structure looks like ? You must experiment because there is
no way I can dump the needed informations in your brain instantly. There is
a learning curve, then you will be able to ask clearer questions.
Daniel
--
Daniel Veillard | Red Hat Desktop team http://redhat.com/
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]