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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:19:05+00:00 2026-05-31T13:19:05+00:00

The following code snippet returns xml document public XmlDocument GetXMLFile(int ID) { List<UserInfoBE> data

  • 0

The following code snippet returns xml document

public XmlDocument GetXMLFile(int ID)
        {

            List<UserInfoBE> data = GetById(ID);
            DataSet ds = ConvertGenericsListToDataSet(data);
            XmlDocument XmlDoc = new XmlDocument();
            XmlDocument doc = GenerateXMLDeclaration(XmlDoc);//Create xml Declaration
            doc = AddTableTag(doc);//Create parent node USERDATA

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                doc = AddUserinfoTag(doc, dr[8].ToString(), Convert.ToInt32(dr[31].ToString()), Convert.ToString(dr[32].ToString()), dr[3].ToString());
            }

            doc = SetHeirarchyLevel(doc);
            string _errorFile = AppDomain.CurrentDomain.BaseDirectory + "XML\\";
            System.IO.Directory.CreateDirectory(_errorFile);
            _errorFile += "FIle" + DateTime.Now.ToString("dd-MM-yyyy") + ".xml"; 
            XmlNodeList nodes = doc.SelectNodes("USERDATA/Userinfo");
            XmlDocument newXMLDoc = new XmlDocument();
            XmlDocument newDoc = GenerateXMLDeclaration(newXMLDoc);
            newDoc.AppendChild(nodes);            
            doc.Save(_errorFile);
            return doc;
        }

XML file format:

<?xml version="1.0"?>
<USERDATA>
  <Userinfo>
    <Userinfo>
      <Userinfo>
        <Userinfo>
          <Userinfo>
            <Userinfo/>
            <Userinfo>
              <Userinfo/>
            </Userinfo>
          </Userinfo>
          <Userinfo>
            <Userinfo/>
            <Userinfo/>
          </Userinfo>
        </Userinfo>
      </Userinfo>
    </Userinfo>
  </Userinfo>
</EDVDATA>

Question how do get file in following format

<Userinfo>
        <Userinfo>
          <Userinfo>
            <Userinfo>
              <Userinfo>
                <Userinfo/>
                <Userinfo>
                  <Userinfo/>
                </Userinfo>
              </Userinfo>
              <Userinfo>
                <Userinfo/>
                <Userinfo/>
              </Userinfo>
            </Userinfo>
          </Userinfo>
        </Userinfo>
      </Userinfo>

What i have tried is saving the return doc object (Xml file) in a folder.
then created a new xmldocument object and trying to append Xmlnodelist which userinfo structure(just above) in new xmlobject

newDoc.AppendChild(nodes); line throws an error

cannot convert from ‘System.Xml.XmlNodeList’ to ‘System.Xml.XmlNode’

any help is very much appreciated.

  • 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-31T13:19:06+00:00Added an answer on May 31, 2026 at 1:19 pm

    You are trying to append multiple nodes but the function takes single node to append at a time. Try this:

    foreach(XmlNode node in nodes)
    {
        newDoc.AppendChild(node);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using following code to get List from xml file - public static
Question: Given the following code snippet: bool foo(int n) { for(int i=3;i<sqrt(n)+0.5;i+=2) { if((n%i)==0){
I have the following code snippet: class Cert { public static void main(String[] args)
The following code snippet returns an array of PropertyInfo objects that have a defined
I have the following code snippet: $.getJSON(http://localhost:8080/images, function(data) { var items = []; $.each(data,
i have the following code snippet. in which i just want to return PartyName
Given the following code snippet: $i= 11; function get_num() { global $i; return (--$i
The following code snippet on SQL server 2005 fails on the ampersand '&': select
The following code snippet is from The Official GNOME 2 Developer's Guide : GMemChunk
The following code snippet attempts to create a Tib DaemonManager connecting to a particular

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.