Re: [xml] Inserting node using xpath and schema

Hi Joe,

Did you look at the site ?

It contains developer documentation, including samples that should help you to proceed.
(it worked for me)

I'm fairly new to libxml2 and could not find answers to my questions
below by searching the FAQ and list archives. I'm trying to determine
how I can use libxml2 to accomplish the following:

- I have a parsed XML document in memory
- I have multiple schemas for the document (a base schema and
- I have an Xpath element expression and an element value


I want to be able to add the new element and value to the document based
on the Xpath expression and the schemas. The schema contains sequences
so the Xpath element has to inserted as a child node in between existing

This sounds pretty straight forward, but I must say that it is not to clear to me what you actually want todo. For xpath coding see http://

I can add a child node but its always after all of the existing

Are there APIs that allow me to insert a node in between existing
sibling nodes?


Is there a way to use a schema to tell libxml2 to insert a node as a
child of a parent and the schema is used to determine the proper
location of the node amongst the existing children?

Don't know, I didn't do too much with the schema parts of the code. This sounds as a piece of custom (your own) logic but I could be wrong.

If you wonder how you can use these APIs, see examples/index.html

Thanks in advance,

It would probably help to post more specific questions in order to get an answer.

Kind Regards,


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