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

  • Home
  • SEARCH
  • 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 3874402
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:08:51+00:00 2026-05-19T22:08:51+00:00

This is probably a very newbie question but what I’m trying to do is

  • 0

This is probably a very newbie question but what I’m trying to do is write a function which returns something like XMLWriter and then adds its contents to another xmlwriter.

For example:

  XmlWriter ToXML()
    {
        XmlWriterSettings oSettings = new XmlWriterSettings();
        oSettings.Indent = true;
        oSettings.OmitXmlDeclaration = false;
        oSettings.Encoding = Encoding.Unicode;
        Stream output = Stream.Null;

        XmlWriter writer = XmlWriter.Create(output, oSettings);
        {
            writer.WriteStartDocument(true);
            writer.WriteComment("This BaseSprite was created by the in-phone level editor");

            writer.WriteStartElement("testelement");

            writer.WriteStartAttribute("Name");
            writer.WriteValue("John Howard");
            writer.WriteEndAttribute();

            writer.WriteEndElement();
        }

        return writer;
    }

   void SomeOtherFunction()
   {
      XMLWriter xmlthing;

   // add xml things to it

   xmlthing +=  ToXML(); // now the contents of ToXML has been added in to xmlthing
  }

Is this possible?

*Question updated:

XmlWriter writer;
        XDocument doc = new XDocument();
        {
            writer = doc.CreateWriter();

            writer.WriteStartDocument(true);
            writer.WriteComment("This BaseSprite was created by the in-phone level editor");

            writer.WriteStartElement("testelement");

            writer.WriteStartAttribute("Name");
            writer.WriteValue("John Howard");
            writer.WriteEndAttribute();

            writer.WriteEndElement();

            writer.Close();
        }

        XDocument doc2 = new XDocument();
        {
            writer = doc2.CreateWriter();

            writer.WriteStartDocument(true);

            writer.WriteStartElement("testnestedelement");

            writer.WriteStartAttribute("DUUUUUDE");
            writer.WriteValue("WHERES MY CAR!?");
            writer.WriteEndAttribute();

            writer.WriteEndElement();

            writer.Close();
        }

        doc.Element("testelement").Add(doc2); // how can I make it so that doc2 is added as a nested element in 'testlement' from doc?
  • 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-19T22:08:51+00:00Added an answer on May 19, 2026 at 10:08 pm

    I would prefer to use XmlDocument if you need to compose the Xml among many function in your app.
    http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx
    or XDocument in Silverlight:
    http://msdn.microsoft.com/en-us/library/system.xml.linq.xdocument%28v=VS.95%29.aspx
    then you create a single XDocument or XmlDocument and you pass it across all the functions needed to manipulate it.

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

Sidebar

Related Questions

This is probably very simple, but I am trying to make something with has
Okay, this is probably a very newbie question, but how can I get to
This is a very newbie question and i will probably get downvoted for it,
This is probably a very silly question. I am trying to do a geolocation
I know this is probably a very simple question but how would I do
I'm new to Xcode. This is probably a very simple question to you, but
Problem : This is a probably a very basic question, but how do I
This is probably VERY simple and silly, but I am trying to use jQuery
I'm sorry for this ( probably very ) noob question, but i've been asked
This probably very easy when you know how, but I don't :) I'm trying

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.