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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:57:29+00:00 2026-05-16T23:57:29+00:00

I am using the following methods to download an xml file private void LoadXMLFile()

  • 0

I am using the following methods to download an xml file

private void LoadXMLFile()
{
  WebClient xmlClient = new WebClient();
  xmlClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(XMLFileLoaded);
  xmlClient.DownloadStringAsync(new Uri("chart.xml", UriKind.RelativeOrAbsolute));
}

void XMLFileLoaded(object sender, DownloadStringCompletedEventArgs e)
{
  if (e.Error == null)
  {
    string xmlData = e.Result;
    HtmlPage.Window.Alert(xmlData);
    x2 = new XDocument(xmlData);
  }
} 

I want to use the information inside xmlData to build an xDocument, like I am trying to do in my last line. It does not give any errors but my program does not work so I must not be correctly making the xDocument. Assiging an xml document directly to x2 like this

x2 = Xdocument.Load("chart.xml")

works.

But I need to do it through webclient. what am I doing wrong here

  • 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-16T23:57:29+00:00Added an answer on May 16, 2026 at 11:57 pm

    Once you’ve got the xmlData string, it’s easy – use XDocument.Parse:

    XDocument doc = XDocument.Parse(xmlData);
    

    Could you elaborate why you need to use WebClient rather than XDocument.Load though? Is it to make the call asynchronous?

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

Sidebar

Related Questions

I am using the following methods: public void M1(Int32 a) { // acquire MyMutex
I have parsed XML using both of the following two methods... Parsing the XmlDocument
I am using the following method to browse for a file: OpenFileDialog.ShowDialog() PictureNameTextEdit.Text =
I am using the following method for reading Csv file content: /// <summary> ///
I'm using the following code to download a page through a POST request: require
I'm using the following method to send mail from Python using SMTP. Is it
I am using the following method: set_browser_log_level 'off' but my log level continues to
I have a partial that renders a select box using the following method: <%=
Using an idea from Bob King idea I wrote the following method. It works
I have tried using the obvious method as outlined in the following example but

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.