Hi there, In C++, I use following code to output bool: MSXML2::IXMLDOMNodePtr pNode = pXMLDoc->createElement(_T("TestNode")); pNode->put_text(CString(_variant_t(false))); When saving, it output: <TestNode>0</TestNode> But I want: <TestNode>false</TestNode> Should I use "pNode->put_text(_T(false))" directly? Or are there any method to write bool value to true/false string directly? Thanks much. Layman
* Layman wrote in microsoft.public.xml: >In C++, I use following code to output bool: > > MSXML2::IXMLDOMNodePtr pNode = pXMLDoc->createElement(_T("TestNode")); > pNode->put_text(CString(_variant_t(false))); > >When saving, it output: ><TestNode>0</TestNode> > >But I want: ><TestNode>false</TestNode> > >Should I use "pNode->put_text(_T(false))" directly? Or are there any >method to write bool value to true/false string directly? There may be other COM/ATL/MFC constructs to achieve the conversion from the false boolean to the string "false", but there is no MSXML-specific one (assuming MSXML does not support passing the VARIANT_FALSE directly) so passing the string literal should be the way to go. -- Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de 68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
"Bjoern Hoehrmann" wrote in message news:di4c541easa9grtfu7amccrf623l1kfub0@hive.bjoern.hoehrmann.de... >* Layman wrote in microsoft.public.xml: >>In C++, I use following code to output bool: >> >> MSXML2::IXMLDOMNodePtr pNode = >> pXMLDoc->createElement(_T("TestNode")); >> pNode->put_text(CString(_variant_t(false))); >> >>When saving, it output: >><TestNode>0</TestNode> >> >>But I want: >><TestNode>false</TestNode> >> >>Should I use "pNode->put_text(_T(false))" directly? Or are there any >>method to write bool value to true/false string directly? > > There may be other COM/ATL/MFC constructs to achieve the conversion from > the false boolean to the string "false", but there is no MSXML-specific > one (assuming MSXML does not support passing the VARIANT_FALSE directly) > so passing the string literal should be the way to go. > -- > Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de > Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de > 68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ I am interested in this also, but I assume the answer is in the documentation; I have not looked yet. I am hoping there is an if statement that allows us to generate either "yes" or "no":
On Mon, 16 Jun 2008 15:15:39 +0800, Bjoern Hoehrmann wrote: > * Layman wrote in microsoft.public.xml: >> In C++, I use following code to output bool: >> >> MSXML2::IXMLDOMNodePtr pNode = >> pXMLDoc->createElement(_T("TestNode")); >> pNode->put_text(CString(_variant_t(false))); >> >> When saving, it output: >> <TestNode>0</TestNode> >> >> But I want: >> <TestNode>false</TestNode> >> >> Should I use "pNode->put_text(_T(false))" directly? Or are there any >> method to write bool value to true/false string directly? > > There may be other COM/ATL/MFC constructs to achieve the conversion from > the false boolean to the string "false", but there is no MSXML-specific > one (assuming MSXML does not support passing the VARIANT_FALSE directly) > so passing the string literal should be the way to go. Thanks a lot. It seems that I should write such a utility function by myself.