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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:55:15+00:00 2026-05-28T04:55:15+00:00

I was previously loading an XML file by using: XDocument doc = XDocument.Load(File.xml); Visit(doc.Root);

  • 0

I was previously loading an XML file by using:

        XDocument doc = XDocument.Load("File.xml");
        Visit(doc.Root);

Now I want to load the file by using a FileUpload box:

        XmlDocument doc = new XmlDocument();
        doc.Load(FileUpload1.FileContent);
        Visit(doc.root);

But now I’m getting an error on “(doc.root)” . It says that “does not contain a definition for ‘Root’ and no extension method ‘Root’ accepting a first argument type”. What am I doing wrong?

  • 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-28T04:55:15+00:00Added an answer on May 28, 2026 at 4:55 am

    That is because XmlDocument doesnt have a root property; The root of the XmlDocument is represented by the DocumentElement property of the object, in your case: doc.DocumentElement and since your method receives an XElement parameter as input you will need to convert the XmlElement to an XElement before passing it into your Visit() method. Use the function below for doing it.

      /// <summary>  
      /// Converts an XmlElement to an XElement.  
      /// </summary>  
      /// <param name="xmlelement">The XmlElement to convert.</param>  
      /// <returns>The equivalent XElement.</returns>  
      public static XElement ToXElement(XmlElement xmlelement)  
      {    
         return XElement.Load(xmlelement.CreateNavigator().ReadSubtree());  
      }
    

    Then try calling in this way:

      Visit(ToXElement(doc.DocumentElement));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using an HTTPService in my Flex application. I want to load several
Previously, to read XML in UTF-8 encoding through xstream, I am using DomDriver as
previously i had custom tableviewcell and was loading from Nib.in that i have specified
Currently I am loading data from a previous session into my application using the
Previously, I asked the question . The problem is the demands of our file
Previously I've asked about inserting a column into a dataset . I now have
I'm using the demo example in https://github.com/nicklockwood/AsyncImageView to load images asynchronously, however my app
I made this pacman game using an applet. When the applet finishes loading, it
I am loading a Library on Linux through System.LoadLibrary( ) call. (Previously asked about
When loading data with SubSonic (either using ActiveRecord or a collection), only records with

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.