[xml] Newbie question on libxml
- From: Medi Montaseri <medi montaseri onstor com>
- To: xml gnome org
- Subject: [xml] Newbie question on libxml
- Date: Wed, 09 Nov 2005 10:11:40 -0800
Being new to libXML, and I have the following question:
Say I have the following XML file representing a collection of system
configuration files (a manifest) such as
/etc/foo.conf, /etc/goo.conf that needs to be copied, deleted, etc based
on the operation (COPY, RESET, RESTORE).
<?xml version="1.0" ?>
<!DOCTYPE object
[
<!ELEMENT object (name, type, op+)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT type (#PCDATA)>
<!ELEMENT op (action, src, dst)>
<!ELEMENT action (#PCDATA)>
<!ELEMENT src (#PCDATA)>
<!ELEMENT dst (#PCDATA)>
]>
<object>
<name>/etc/foo.conf</name>
<type>file</type>
<op>
<action>RESET</action>
<src>/tmp/foo.conf.orig</src>
<dst>/etc/foo.conf</dst>
</op>
<op>
<action>COPY</action>
<src>copy_src</src>
<dst>copy_dst</dst>
</op>
<op>
<action>RESTORE</action>
<src>/tmp/restor.conf.orig</src>
<dst>/etc/restor.conf</dst>
</op>
</object>
I have learned how to read/parse this file via xmlReadFile with
XML_PARSE_NOBLANKS | XML_PARSE_DTDVALID. I have also manged to walk the
tree and print node name and content.
Here is what I want to be able to do:
An operation specific C function (such as processManifestCopy()) would
read/parse this file and then
proceed to identify all the objects (or files) whose op.action is COPY
and then do the appropriate thing.
My question is:
Is there any libxml function that can do some of this work for me. The
only way that I know how to
do this at this point is to walk the tree with xmlDocGetRootElement(),
and xmlNode and
put each object in a struct, then examine the op.action, if this is what
I want, then move on to the next
object, else reuse this struct, such that at the end of the day, I have
a link list of structures.
I'm sure libXML is more powerfull than ... here is a xmlDocPtr, now take
it from here....
As a suggestion, perhaps xmlsoft.org site's author could provide some
SEE ALSO links
in the description area of functions. Currently one learns about a
function such as xmlReadFile()
but what do you do with that, where do you go from here....not
there...basically the old unix man page recommendations.
Thanks everyone ...
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]