creating ELEMENT with default namespace
-
i have the following xml document with a default namespace. something i did all the MSXML4 necessary things to work with the default namespace and got the Xpath expression working with the selectsinglenode() and selectnodes(). now when i create the tag , i get an unwanted empty xmlns attribute in the new tag and its causing all the Xpath expression to break. something something how do i get rid of this xmlns="" attribute? I tried removeNamdItem("xmlns") but it does not work. how do i prevent the empty xmlns attribute from apprearing? a workaround i did was to get xmldoc->getxml(), search and replace the xmlns="" but that is not a viable solution. thanks.. meng
-
i have the following xml document with a default namespace. something i did all the MSXML4 necessary things to work with the default namespace and got the Xpath expression working with the selectsinglenode() and selectnodes(). now when i create the tag , i get an unwanted empty xmlns attribute in the new tag and its causing all the Xpath expression to break. something something how do i get rid of this xmlns="" attribute? I tried removeNamdItem("xmlns") but it does not work. how do i prevent the empty xmlns attribute from apprearing? a workaround i did was to get xmldoc->getxml(), search and replace the xmlns="" but that is not a viable solution. thanks.. meng
Have you tried using
createNode(NODE_ELEMENT, "SECOND", "mynamespace")
to create the element? -
Have you tried using
createNode(NODE_ELEMENT, "SECOND", "mynamespace")
to create the element?thanks for your advise! solved. if (GetDefaultNamespace().IsEmpty()) { // Create element with no namespace spNewNode = spXmlDoc->createNode(MSXML2::NODE_ELEMENT, _bstr_t(_T("SECOND")), ""); } else { // Create element with default namespace spNewNode = spXmlDoc->createNode(MSXML2::NODE_ELEMENT, _bstr_t(_T("SECOND")), _bstr_t(_T("mynamespace"))); } huikm