Re: [xml] need info on using libxml2 - build, merge, template xml files
- From: "Senthil Nathan" <rsennat gmail com>
- To: "Rush Manbert" <rush manbert com>
- Cc: xml gnome org
- Subject: Re: [xml] need info on using libxml2 - build, merge, template xml files
- Date: Fri, 17 Aug 2007 22:55:25 +0530
Hi Rush,
Gr8. Thanks for the info.
And reg. the 4th point, I need to insert the values in the proper places of the DOM tree.
You got it rightly. So how do I get that done??
Senthil
On 8/17/07, Rush Manbert <rush manbert com> wrote:
Senthil Nathan wrote:
> Hi,
> I'm new to use libxml2. I need general clarifications of using libxml2 for
> my application.
>
> Say, I have a XML content as,
>
> <hostName>
> <defaultValue>value</defaultValue>
> <description>
> <shortDescr>Hostname descr.</shortDescr>
> <longDescr>long descr of Hostname</longDescr>
> </description>
>
> <dataType>string</dataType>
> <operations>set,delete</operations>
>
> </hostName>
>
> 1. Here, Is it possible to build a DOM tree using libxml2. (basic question.
> but still)
>
Yes.
> 2. And is it possible to have "description", "datatype", "operations" as
> attributes
> in the DOM tree, instead of as sub nodes of "hostName".
>
I think you need XSLT to do this. Luckily, libxslt is available. You
just read and parse the original XML file, then apply your XSL style
sheet to it.
> 3. Is there anyway to overlay XML file on an existing xml tree. ie., merge /
> append different xml files.
>
Again, XSLT might be your friend here. There have been lots of threads
on the subject of document merging on the Mulberry Tech XSL list. Check out:
http://www.mulberrytech.com/xsl/xsl-list/
You can get high quality help here. My personal experience with libxslt
used in conjunction with libxml2 has been very good. It works very well.
> 4. I have a template XML file and a config XML file. All the values for the
> template should be available in the config file. Is that possible with
> libxml2?
>
So you would have a template file that looks like this:
<hostName>
<defaultValue></defaultValue>
<description>
<shortDescr></shortDescr>
<longDescr></longDescr>
</description>
<dataType></dataType>
<operations></operations>
</hostName>
and, according to your example, you want to insert these values:
value
Hostname descr.
long descr of Hostname
string
set,delete
into the proper places in the DOM structure.
Or maybe just into the proper places in a text file.
Or maybe as attributes on some element.
Do I understand this correctly?
- Rush
--
http://www.jaxtr.com/rsennat - You can call me for free by clicking on this link.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]