Gennady Khokhorin wrote:
Hello, all.
I was trying to create a template from scratch.
Can not insert <?xml-stylesheet tag before the root element, its appear
at the end of xml after root element closing tag. Code is like that:
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* doc = impl->createDocument(
                           NULL,                        // root element
namespace URI.
                           _T("metadata"),    // root element name
                           NULL);                       // document type
object (DTD).
DOMProcessingInstruction* procInstruction =
doc->createProcessingInstruction(_T("xml-stylesheet"),
_T("type=\"text/xsl\" href=\"my.xsl\"")); 
doc->appendChild(procInstruction);

Hope it is not a bug.
No, it's not a bug. Creating the document also creates the document element, and then you "append" a child processing instruction node. You need to use DOMNode::insertBefore() to insert before an existing child.


Also, what command can insert XSD location in the root element like
that:
<metadata xmlns="..." xmlns:xsi="..." xsi:schemaLocation="my.xsd">
You need to add the appropriate attributes to the document element. See DOMElement::setAttributeNS() for more information.

Please consider reading a tutorial on the DOM before posting generic questions. A good tutorial will answer many of your questions, and save lots of bandwidth on the list.

Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to