Re: [xml] need info on using libxml2 - build, merge, template xml files

Senthil Nathan wrote:
I'm new to use libxml2. I need general clarifications of using libxml2 for
my application.

Say, I have a XML content as,

             <shortDescr>Hostname descr.</shortDescr>
             <longDescr>long descr of Hostname</longDescr>



1. Here, Is it possible to build a DOM tree using libxml2. (basic question.
but still)


2. And is it possible to have "description", "datatype", "operations" as
    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:

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

So you would have a template file that looks like this:



and, according to your example, you want to insert these values:
Hostname descr.
long descr of Hostname

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

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]