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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:35:18+00:00 2026-06-11T21:35:18+00:00

OuterXml – gets the XML markup representing the current node and all its child

  • 0

OuterXml – gets the XML markup representing the current node and all its child nodes.

InnerXml – gets the XML markup representing only the child nodes of the current node.

But for XMLDocument does it really matter? (result-wise, well I know it doesn’t matter, but logically?).

Example:

XmlDocument doc = new XmlDocument();
doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" +
    "<title>Pride And Prejudice</title>" +
    "</book>");

string xmlresponse = doc.OuterXml;
string xmlresponse2 = doc.InnerXml;

In simple words, though both xmlresponse and xmlresponse2 will be the same in the code above. Should I prefer using OuterXml or InnerXml?

  • 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-11T21:35:20+00:00Added an answer on June 11, 2026 at 9:35 pm

    If you are trying to find why they OuterXml and InnerXml are the same for XmlDocument: look at what XmlDocument represents as node – it is parent of whole Xml tree. But by itself it does not have any visual representation – so “Me”+ “content of children” for it is the same as “content of children”.

    You can write basic code to walk XmlNode + children and pass XmlDocument to see why it behaves this way:

    XmlDocument doc = new XmlDocument();
    doc.LoadXml("<?xml version='1.0' ?><root><item>test</item></root>");
    
    Action<XmlNode, string> dump=null;
    dump = (root, prefix) => {
      Console.WriteLine("{0}{1} = {2}", prefix, root.Name, root.Value); 
      foreach (XmlNode n in root.ChildNodes)
      {
        dump(n, "  " + prefix);
      }
    };
    
    dump(doc,"");
    

    Output shows that XmlDocument there is nothing in XmlDocument itself that have visual representation and the very first node that have text representation is child of it:

    #document = 
      xml = version="1.0"
      root = 
        item = 
          #text = test
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

System.Xml.XmlDocument.OuterXml() will generate (for example) <list id=myBooks> <book id=123 name=XML for muppets /> <book
i want to compare xml document. some are 50k+. i'm comparing the OuterXml. is
I have this XML file that I parse into its elements and create a
I'm transforming xml using the following code. It works fine for one xslt but
When I build XML up from scratch with XmlDocument , the OuterXml property already
I want to read entire data/all nodes from XmlDocument. I don't want to use
I am modifying my XML using LINQ: Dim feedXML As XDocument = XDocument.Parse(m_xmld.OuterXml.ToString()) Dim
I'm having problems while attaching some strings to some XML nodes. To explain this
Hey all i have an XML file that i am trying to loop though.
Reading outer Xml from an XmlReader , how do I remove whitespaces(\n\t\t) in my

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.