[xml] Edit a document created with the TextWriter interface
- From: Francesco Pretto <ceztkoml gmail com>
- To: xml gnome org
- Subject: [xml] Edit a document created with the TextWriter interface
- Date: Tue, 16 Nov 2010 02:07:12 +0100
Hello, I'm a newcomer!
I always used with satisfaction the TextWriter interface to create xml
documents. Now I got the need to perform simple edits of the document
after I actually produced it with the TextWriter. Actually, it's just
an "AUTH" element to be filled later with a security hash calculated
in the final document with "AUTH" element empty (the appropriateness
of this is debatable but can't change it: not mine project ;) ). The
question is: can I get a pointer (for example: know the xmlNodePtr) of
an element while creating it with TextWriter so I can modify it later?
If this is not possible/supported, what are the simpler alternatives?
Xpath on the created document or use of another interface?
It follows some sample code to just show the use-case.
Thanks,
Francesco
-----------------------------------------------------------
xmlDocPtr doc;
xmlTextWriterPtr writer = xmlNewTextWriterDoc(&doc, 0);
xmlTextWriterStartDocument(writer, NULL, "UTF-8", NULL);
xmlTextWriterStartElement(writer, BAD_CAST "AUTH");
xmlTextWriterEndElement(writer);
// Get a "pointer" to the AUTH element
xmlTextWriterEndDocument(writer);
xmlChar *buffer;
int size;
xmlDocDumpMemory(doc, &buffer, &size);
// Calculate the security hash from the buffer
// Fill the "AUTH" element with the hash
// ...
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]