Prev: Access violation error
Next: loading xml file in winme
From: PGP on 6 Jul 2007 14:21 I am trying to use MXXMLWriter with put_indent(VARIANT_TRUE) to get formatted xml. It works great if the output type is BSTR. If i set a DOMDocument as the output type, i get an empty document when i save. If this sounds familiar, please let me know what's wrong. CComPtr<IMXWriter> pWriter; HRESULT hr = pWriter.CoCreateInstance(__uuidof(MXXMLWriter), NULL); CComPtr<ISAXXMLReader> pReader; hr = pReader.CoCreateInstance(__uuidof(SAXXMLReader), NULL); CComQIPtr<ISAXContentHandler> pContentHandler(pWriter); hr = pReader->putContentHandler(pContentHandler); IXMLDOMDocumentPtr pXMLDom = NULL ; CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, __uuidof(IXMLDOMDocument), (void**)&pXMLDom) ; pXMLDom->put_async(VARIANT_FALSE) ; pXMLDom->put_validateOnParse(VARIANT_FALSE) ; pXMLDom->put_resolveExternals(VARIANT_FALSE) ; pXMLDom->put_preserveWhiteSpace(VARIANT_FALSE) ; CComVariant var((LPUNKNOWN)pXMLDom) ; hr = pWriter->put_output(var); pWriter->put_indent(VARIANT_TRUE) ; hr = pReader->parseURL(szFile) ; CComVariant savefile(_T("c:\\1.xml")) ; pXMLDom->save(savefile) ; The xml i use to test is - <?xml version="1.0" encoding="utf-8"?> <Root><Child>Node Value = 0</Child><Child>Node Value = 1</Child><Child>Node Value = 2</Child><Child>Node Value = 3</Child><Child>Node Value = 4</Child><Child>Node Value = 5</Child><Child>Node Value = 6</Child><Child>Node Value = 7</Child><Child>Node Value = 8</Child><Child>Node Value = 9</Child></Root> TIA Priyesh
|
Pages: 1 Prev: Access violation error Next: loading xml file in winme |