sperlis
February 6th, 2008, 11:55 AM
Hi all,
I am using the MSXML library to process XML documents. I have a requirement to merge a raw XML fragment (from a string) into an existing document. Adding it under an arbitrary element. I've tried this:
MSXML2::IXMLDOMElementPtr current;
wchar_t *xml_buffer;
.
.
.
MSXML2::IXMLDOMDocumentPtr doc;
HRESULT hResult = doc.CreateInstance(__uuidof(MSXML2::DOMDocument40));
if (SUCCEEDED(hResult)) {
doc->loadXML(xml_buffer);
MSXML2::IXMLDOMElementPtr new_sub = doc->documentElement;
new_sub = doc->removeChild(new_sub);
if (new_sub != NULL) {
current->appendChild(new_sub);
}
}
doc.Release();
This throws an "Invalid Argument" exception.
Is this even the way to go?
While a "get_xml" member exists, "put_xml" is missing in action, I guess, so there must be a different way to do this.
Thanks,
I am using the MSXML library to process XML documents. I have a requirement to merge a raw XML fragment (from a string) into an existing document. Adding it under an arbitrary element. I've tried this:
MSXML2::IXMLDOMElementPtr current;
wchar_t *xml_buffer;
.
.
.
MSXML2::IXMLDOMDocumentPtr doc;
HRESULT hResult = doc.CreateInstance(__uuidof(MSXML2::DOMDocument40));
if (SUCCEEDED(hResult)) {
doc->loadXML(xml_buffer);
MSXML2::IXMLDOMElementPtr new_sub = doc->documentElement;
new_sub = doc->removeChild(new_sub);
if (new_sub != NULL) {
current->appendChild(new_sub);
}
}
doc.Release();
This throws an "Invalid Argument" exception.
Is this even the way to go?
While a "get_xml" member exists, "put_xml" is missing in action, I guess, so there must be a different way to do this.
Thanks,