Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8881743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:24:22+00:00 2026-06-14T20:24:22+00:00

This answer briefly touched on this topic, but did not mention the problem I

  • 0

This answer briefly touched on this topic, but did not mention the problem I am having.

Take a look at this fiddle.

As you can see from the alert message, jQuery made a number of changes I was not expecting:

  • collapsed the original <node></node> into a self-closing tag (<node />)
  • $('<SelfClosingNode />') became <selfclosingnode xmlns="http://www.w3.org/1999/xhtml"></selfclosingnode>, eg. made the tag name lower-case, added the xmlns attribute, and split it into opening and closing tags

I need to be able to insert EXACT xml, i.o.w. I don’t want jQuery to mess with my mark-up structure!

Thanks in advance for the help…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:24:23+00:00Added an answer on June 14, 2026 at 8:24 pm

    Good news is that you can force the case sensitivity for your SelfClosingNode. See below:

    var xml_string = $("#xml-data").html();
    try{
        var xml = $.parseXML(xml_string);
        var $xml = $(xml);
    
        var newStuff = $.parseXML("<SelfClosingNode />");
        var $newStuff = $(newStuff.documentElement);
        $xml.find("project").append($newStuff);
    
        console.log(xml.documentElement);    
    
        // Needed if you are running in IE
        if (window.ActiveXObject) {
          var new_xml_string = xml.xml;
        } else {
          var new_xml_string = (new XMLSerializer()).serializeToString(xml);
        }
    
        alert( new_xml_string );
    
    } catch(e){
    
        alert(e);
    
    }
    

    Unfortunately, it is the XMLSerializer that is forcing the self closing tags, not JQuery. Self closing tags are considered valid for XML, but not for XHTML. If you look into the console log output (see the console.log statement above) you can see that the tags are not actually self-closed in the DOM.

    One quick and dirty way is to change <node></node> to <node><!-- comment --></node>.

    Otherwise your external program may have to be made more flexible to read these self-closing tags, as they are valid XML. There are some questions on replacing self-closing tags in existing XML, e.g. Replace XML self-closing tag with empty one

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that this question is repeated one. But no one could answer briefly
i've looked briefly through similar questions but i could not find the answer i
I checked this question , but it doesn't appear to answer my problem, which
This may not be specific enough to answer but I'm hoping there is some
Trying this answer and not having any luck: I am using the SQLite Database
This answer has helped me largely but hasn't fully resolved my issues. I'm using
in this answer he said that i can use RIA services while creating my
I've tried searching high and low for the answer to this weird problem. My
I saw this answer to a similar question , but it always scares me
All, This question probably has a very simple answer - something I'm overlooking. But

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.