I haven't worked with the C++ version much, but in general the concept
ought to be much the same from one version of the DOM to another. In Java,
it would be roughly as follows. For more detail, see the DOM specification
and/or the XML-DEV mailing list.
//// parse your document into the DOM, obtaining a Document object.
//// In the following, I'm assuming that object is in a variable called
myDocument.
// Find the TypeB element. One easy but inefficient solution -- please note
that this
// is not namespace-aware and does not handle the case where there is not
TypeB or
// more than one -- would be:
Nodelist allTypeBs=myDocument.getElementsByTagName("TypeB");
Node firstTypeB=(Element) allTypeBs.item(0);
// Create a TypeC element. Again, please note that namespaces would make
this a bit
// more complicated.
Element myTypeC=myDocument.createElementNS(null,"TypeC");
// Insert the latter after the former. Note that there is no insertAfter()
operation in the DOM,
// so you insert it before the next sibling instead. It can be done as a
one-liner, but for pegagogical purposes:
Node parent=firstTypeB.getParent();
Node nextSibling=firstTypeB.getNextSibling();
parent.insertBefore(myTypeC,nextSibling);
//// write your now-modified DOM out to a file.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]