Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: loadXML returns XML_E_INVALIDATROOTLEVEL

From: "Joe Fawcett" <joefawcett@---------.------>
To: NULL
Date: 12/1/2005 8:54:00 AM
"Eric C" <Eric C@d...> wrote in message 
news:5B46CC41-3DAE-4701-B031-B24C90EECFE3@m......
>I have a snippet of code inside a legacy VC6 MFC app. This code uses the
> MSXML 4 SDK. The code creates a document node and inserts one child 
> element.
> There is no CDATA, just elements with attributes. I write the XML to a
> database on another machine.
>
> Shortly after, I load the XML back from the database in a CString, and try
> to put it back in a DOM. Here is the code snippet:
>
> BOOL LoadXMLToDOM(CString & xmlFileContents)
> {
> HRESULT hr = 0;
> VARIANT_BOOL status = TRUE;
> COleVariant fileContents(xmlFileContents);
>
> CComPtr<IXMLDOMDocument2> pXMLDom = ::DOMFromCOM(); // calls CCI()
> pXMLDom->put_async(VARIANT_FALSE);
> pXMLDom->put_validateOnParse(VARIANT_FALSE);
> pXMLDom->put_resolveExternals(VARIANT_FALSE);
>
> hr = pXMLDom->loadXML(fileContents.bstrVal, &status) ;
>
> The XML looks like this:
>
> <?xml version='1.0' encoding='utf-16'?>
> <FILE>
> <NODE DATA1="ABC" DATA2="1417131518171D1F191311131118101511111116"
> DATA3="32663"/>
> </FILE>
>
> In the file, each character is two bytes. I've tried using UTF-8, UTF-16,
> with or without the header element and the BOM. Opening the XML in MSIE6
> fails but the error message is clipped. It opens and displays as a tree in
> FireFox 1.5. Online validators complain about not having a DTD but that's
> about it.
>
> There is precious little documentation on what XML_E_INVALIDATROOTLEVEL
> means and what to do about it.
>
> I'm sure it's something I've done, but I don't know what. I've used Xerces
> mostly for XML processing and this is my first time using MSXML other than
> "just playing".
>
> Any ideas would be appreciated.
>
> Eric

Given your XML document looks fine I've seen this happen when there is 
unintentional whitespace at the start of the document.


-- 
Joe Fawcett -  XML MVP

https://mvp.support.microsoft.com/profile=8AA9D5F5-E1C2-44C7-BCE8-8741D22D17A5 




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent