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 509501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:01:02+00:00 2026-05-13T07:01:02+00:00

System.Xml.XmlDocument.OuterXml() will generate (for example) <list id=myBooks> <book id=123 name=XML for muppets /> <book

  • 0

System.Xml.XmlDocument.OuterXml() will generate (for example)

<list id="myBooks">
  <book id="123" name="XML for muppets" />
  <book id="456" name="HTML for fools" />
</list>

If you want to embed this xml into HTML page then it will work fine in IE (as xml data islands are an extension to the html standards)

However for Firefox you need to load this unknown html tag that happens to contain xml into a DOMParser using something like

var list = document.getElementById("myBooks");
var doc = new DOMParser().parseFromString(list.outerHTML);

However because <tag /> is not == <tag></tag> in HTML firefox will see list.outerHTML as

<list>
  <book id="123" name="XML for muppets">
     <book id="456" name="HTML for fools">
     </book>
  </book>
</list>

So how do I get XmlDocument.OuterXml() to output xml will full closing tags rather than shorthand ?

EDIT – Added example to illustrate

<html><body>
<xml id="myBooks">
<list>
  <book id="123" name="XML for muppets" />
  <book id="456" name="HTML for fools" />
</list>
</xml>
<script>
var oXml = document.getElementById("myBooks");
alert(oXml.innerHTML);
</script>
</body></html>
  • 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-05-13T07:01:03+00:00Added an answer on May 13, 2026 at 7:01 am

    I am confused. What makes you think Firefox will not be able to interpret the self-closing XML tags? XHTML which is supported by every major browser including Firefox, allows you to use such self-closing tags anywhere that you don’t have content. Why would an XML data island be any different?

    Additionally, you may want to look at using XmlTextWriter to write to a StringWriter or something. You can configure an XmlTextWriter with an XmlWriterSettings that specifies an XmlOutputMethod of Html that may provide more HTML-like output.

    UPDATE
    Unfortunately I just tested this and OutputMethod property has an internal setter. But out of curiosity I used reflection to set it and it did in fact change the XML output such that the self-closing tags were turned into separate close tags. Code is below.

    var stream = new System.IO.StringWriter();
    var xmldoc = new System.Xml.XmlDocument();
    xmldoc.LoadXml("<root><child><grandchild /></child><child /></root>");
    
    var settings = new System.Xml.XmlWriterSettings();
    var propInfo = settings.GetType().GetProperty("OutputMethod");
    propInfo.SetValue(settings, System.Xml.XmlOutputMethod.Html, null);
    var writer = System.Xml.XmlWriter.Create(stream, settings);
    
    xmldoc.Save(writer);
    
    stream.ToString().Dump();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 300k
  • Answers 300k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You haven't really shown enough code - in particular, you… May 13, 2026 at 8:00 pm
  • Editorial Team
    Editorial Team added an answer Make sure that the anonymous web user account (NETWORK SERVICE… May 13, 2026 at 8:00 pm
  • Editorial Team
    Editorial Team added an answer If you want exactly that result you can't use any… May 13, 2026 at 8:00 pm

Related Questions

For a instance we have some IHttpHandler. where we have two valiables: XmlElement xmlResponse
I have implemented a csv file builder that takes in an xml document applies
I have a WCF service which accepts a string as a paramter for one
Let's say I have a System.Xml.XmlDocument whose InnerXml is: <comedians><act id=1 type=single name=Harold Lloyd/><act
In PowerShell you can use [xml] to mean [System.Xml.XmlDocument]. Do you know where I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.