![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - MSXML and Whitespace >Thread Next - Re: MSXML and Whitespace Re: MSXML and WhitespaceTo: NULL Date: 7/8/2006 8:35:00 PM
"wdhough" <wdhough@d...> wrote in message
news:4AA8D5DC-909E-42A5-874B-2885E0387CD1@m......
> Hi,
>
> I have problems inserting whitespace into my xml document. I have the
> following code.
>
> //init com for this thread
> CoInitialize(NULL);
>
> //create an instance of it
> HRESULT hr = doc_ptr.CreateInstance(_uuidof(MSXML2:OMDocument60));
> if (FAILED(hr))
> {
> MessageBeep(0);
> CoUninitialize();
> return;
> }
> doc_ptr->async = VARIANT_FALSE;
> HRESULT res = doc_ptr->put_preserveWhiteSpace(TRUE);
> //
> MSXML2::IXMLDOMDocument3::createDocumentFragment();
> ///
> MSXML2::IXMLDOMProcessingInstructionPtr pPI = NULL;
> //doc_ptr->preserveWhiteSpace = TRUE;
> pPI = doc_ptr->createProcessingInstruction
> ("xml", "version='1.0' encoding='UTF-8'");
>
> _variant_t vNullVal;
> vNullVal.vt = VT_NULL;
> doc_ptr->insertBefore(pPI, vNullVal);
>
> ///
> //Create document element.
> MSXML2::IXMLDOMNodePtr pRootNode= NULL;
> _variant_t varNodeType((short)MSXML2::NODE_ELEMENT);
>
> //create a node, whos name should be the document element name
> CString str;
> str.LoadString(IDS_XML_DOC_ELEM);
> pRootNode= doc_ptr->createNode(varNodeType,
> ((LPCTSTR)str),_T(""));
> doc_ptr->appendChild(pRootNode);
> //this part adds a node under neath the root with some text as its value
but
> the spacing gets cut off at the end.
> MSXML2::IXMLDOMNodePtr temp;
> temp = NULL;
> str.LoadString(IDS_XML_NODE_NAME);
> temp = doc_ptr->createNode(varNodeType,(LPCTSTR)str,_T(""));
> temp->nodeTypedValue = _T("this is a test of spacing ");
> pRootNode->appendChild(temp);
>
> The problem is the white space is removed from the temp node.
>
> any ideas please
>
The problem with C/C++ code is that it's often difficult to see what the
problem might be due to all the textual overhead in the code. Can you
reproduce the problem with a VBScript and post that instead?
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
