Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - loadXML returns XML_E_INVALIDATROOTLEVEL >Thread Next - Re: loadXML returns XML_E_INVALIDATROOTLEVEL Re: loadXML returns XML_E_INVALIDATROOTLEVELTo: 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
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
