MSXML Sets the Namespace Attribute to an Empty Value for Child Nodes
- From: Daniel Lidström <someone@xxxxxxxxxxxxx>
- Date: Wed, 28 Sep 2005 16:02:10 +0200
Hi,
I have a piece of code that produces this xml:
<?xml version="1.0"?>
<root xmlns="nameSpace"><sub xmlns=""/></root>
where I would like it to produce this xml:
<?xml version="1.0"?>
<root xmlns="nameSpace"><sub/></root>
i.e. the sub element should not have an empty value for the namespace
attribute.
The code follows below. I'm using Visual Studio 7.1.3088 on Windows XP.
Anyone have a solution?
#import <msxml3.dll> named_guids
#include <msxml.h>
#include <iostream>
int main()
{
CoInitialize(NULL);
MSXML2::IXMLDOMDocumentPtr m_xmldoc;
m_xmldoc.CreateInstance(MSXML2::CLSID_DOMDocument);
MSXML2::IXMLDOMProcessingInstructionPtr pi;
pi = m_xmldoc->createProcessingInstruction("xml", "version='1.0'");
if( pi!=NULL )
{
m_xmldoc->appendChild(pi);
pi.Release();
}
MSXML2::IXMLDOMElementPtr pe;
pe = m_xmldoc->createNode("element", "root", "nameSpace");
m_xmldoc->appendChild(pe);
pe.Release();
MSXML2::IXMLDOMNodePtr proot(m_xmldoc->GetdocumentElement());
MSXML2::IXMLDOMNodePtr
newNode(m_xmldoc->createNode(_variant_t((short)MSXML2::NODE_ELEMENT),
"sub", ""));
proot->appendChild(newNode);
newNode.Release();
proot.Release();
std::cout << m_xmldoc->Getxml() << std::endl;
m_xmldoc.Release();
CoUninitialize();
return 0;
}
Thanks in advance!
--
Daniel
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
.
- Follow-Ups:
- Re: MSXML Sets the Namespace Attribute to an Empty Value for Child Nodes
- From: Igor Tandetnik
- Re: MSXML Sets the Namespace Attribute to an Empty Value for Child Nodes
- Prev by Date: Re: VC6 to VC8 Conversion Compilation Errors
- Next by Date: Re: MSXML Sets the Namespace Attribute to an Empty Value for Child Nodes
- Previous by thread: libjpeg with customized output module
- Next by thread: Re: MSXML Sets the Namespace Attribute to an Empty Value for Child Nodes
- Index(es):
Relevant Pages
|
|