Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Invalid character error in XML file

From: "Sandeep" <Spexy.Sandy@-----.--->
To: NULL
Date: 2/1/2006 11:11:00 PM
The code snippets I use to create the document is as follows:

-----------------------------------------------------------------------------
// creating the document
MSXML2::IXMLDOMElementPtr               pRootElement        = NULL;
MSXML2::IXMLDOMProcessingInstructionPtr pProcessInstruction = NULL;
HRESULT hr = NULL;
 MSXML2::IXMLDOMDocumentPtr   pDoc = NULL;

 variant_t varXml(_T("C:\\NeXML.xml"));
 _variant_t varOut((bool) true );

hr = pDoc.CreateInstance(MSXMLPROGID);
pDoc->async = false;
varOut = pDoc->load(varXml);

pProcessInstruction = pDoc->createProcessingInstruction( _T("xml"),
_T("version='1.0' encoding='UTF-16'"));
_variant_t vNullVal;
vNullVal.vt = VT_NULL;

hr = pDoc->insertBefore(pProcessInstruction, vNullVal);


pRootElement = pDoc->createElement(_T("DataRoot")); // bstRootNodeName
is passed to this function
pRootElement->setAttribute(
                  _T("xmlns:od"),
                  _T("urn:schemas-microsoft-com:officedata"));
        pRootElement->setAttribute(
                  _T("xmlns:xsi"),
                  _T("http://www.w3.org/2000/10/XMLSchema-instance"));
        pRootElement->setAttribute(
                  _T("xsi:noNamespaceSchemaLocation"),
                  _T("BIDTable.xsd"));

        pDoc->appendChild(pRootElement);


		pDoc->save((LPCTSTR) "C:\\NeXML.xml");}


----------------------------------------------------------------------------------------------------

//Adding the problem data
typedef struct _IID
{
    unsigned long x;
    unsigned short s1;
    unsigned short s2;
    unsigned char  c[8];
} IID;
typedef IID CLSID;
 // Transfer GUID
CString         csGUID;
        CLSID IDVal     = Record.GetTapeFamily();   // IDVal gets a
GUID value
        for (int I = 0; I < sizeof(CLSID)/sizeof(TCHAR); I++)
        {
            csGUID += ((TCHAR *)&IDVal)[I];
        }


// The value of csGUID is put in the xml doc as mormal string.


-------------------------------------------------------------------------------------------------------------

Now some of the guid put or inserte din the document is displayed
properly when the document is opened in IE.
But someof the GUID which are inserted into the document caused problem
and no data is displayed in IE when the doucment is opened. I
When the document is opened in IE, error is displayed in the document
"An invalid character was found in
text content"
 hope now I am clear.

Sandeep



transparent
Print
Mail
Digg
delicious
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