Closed GoogleCodeExporter closed 9 years ago
I am trying to convert MSXML into pugixml? Function i am trying to convert is
as under
CDS_RETVAL CXmlDocument::CreateElement(const std::wstring& name, const
std::wstring& prefix, const std::wstring& nameSpace, CXmlNode& element)
{
CDS_RETVAL retVal;
CComBSTR name_space;
CComBSTR node_name;
CComVariant type;
std::wstring prefix_name;
CComBSTR bstr_prefix_name;
HRESULT hr;
retVal = OK;
type.vt = VT_I4;
//Create node name with prefix
prefix_name = prefix + std::wstring(TEXT(":")) + name;
if (NULL != element.m_XmlNode)
{
#ifdef DEBUG
assert(0);
#else
m_log.AddLog(cModuleUtility, cLevelError, "MEMORY LEAK in CXmlDocument::CreateElement");
#endif
}
//Create the element
type = NODE_ELEMENT;
name_space = nameSpace.c_str();
node_name = name.c_str();
bstr_prefix_name = prefix_name.c_str();
hr = m_XmlDocument->createNode(type, bstr_prefix_name, name_space, &(element.m_XmlNode));
if (FAILED(hr))
{
retVal = CDS_ERROR_UNKNOWN; goto CleanUp;
}
CleanUp:
return retVal;
}
Original comment by sand...@gmail.com
on 25 Sep 2012 at 10:30
You can use namespaces in pugixml just fine - it's similar to what you're doing
in your code, i.e. just create a child with name that contains a semicolon
(and, if necessary, add an xmlns attribute).
I.e.:
pugi::xml_node child = node.append_child("test:nodename");
child.append_attribute("xmlns") = "http://test.org";
The documentation is referring to namespace nodes in XPath - this is a special
concept that is only important for a small fraction of XPath documents, see
http://www.w3.org/TR/xpath/#namespace-nodes
Original comment by arseny.k...@gmail.com
on 25 Sep 2012 at 3:57
Original comment by arseny.k...@gmail.com
on 29 Sep 2012 at 5:58
Original issue reported on code.google.com by
sand...@gmail.com
on 25 Sep 2012 at 10:10