Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. creating ELEMENT with default namespace

creating ELEMENT with default namespace

Scheduled Pinned Locked Moved XML / XSL
xmlquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    huikm
    wrote on last edited by
    #1

    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

    Richard DeemingR 1 Reply Last reply
    0
    • H huikm

      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

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      Have you tried using createNode(NODE_ELEMENT, "SECOND", "mynamespace") to create the element?

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      A 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        Have you tried using createNode(NODE_ELEMENT, "SECOND", "mynamespace") to create the element?

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups