![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: Invalid character error in XML file >Thread Next - Re: Invalid character error in XML file Re: Invalid character error in XML fileTo: 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
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
