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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:24:18+00:00 2026-05-10T22:24:18+00:00

Ok another WPF question, well I guess this is just general .NET. I have

  • 0

Ok another WPF question, well I guess this is just general .NET. I have an xml document retreived from a URL.

I want to get multiple values out of the document (weather data, location, some other strings).

When I use the XmlTextReader I can call my method to pull the values out. The first time I pass the method to search for the xml node and get the value (the XMLTextReader object) I get the right data back, but then the XMLTextReader is dead. Not sure why it gets nulled out. So I’m having to do this UGLY code below in the FindTags… method. I want to just keep passing the xtr (XMLTextreader) back to my find method. Is this the nature of the reader? I don’t want to have to hit the URL each time either… that seems wrong too.

Help.. this just all feels wrong.

Thanks.

        GetWeatherFeed('97229', '//weather//loc//dnam', '//weather//cc//tmp', '/weather/cc/icon'); 

Get WeatherFeed method (snipped)

        System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(Url that retuns xm);         System.Collections.Hashtable ht = new System.Collections.Hashtable();          ht = FindTagsUsingXPthNaviatorAndXPathDocumentNew(xtr, location, temperature, iconid);         lblLocation.Content = ht['Location'].ToString();         lblWeatherCondition.Content = ht['Weather'].ToString();   public System.Collections.Hashtable FindTagsUsingXPthNaviatorAndXPathDocumentNew(System.Xml.XmlTextReader xtr, string nodeToLocate1, string nodeToLocate2, string nodeToLocate3) {     System.Xml.XPath.XPathDocument xpDoc = new System.Xml.XPath.XPathDocument(xtr);     System.Xml.XPath.XPathNavigator xpNav = xpDoc.CreateNavigator();     System.Xml.XPath.XPathExpression xpExpression = xpNav.Compile(nodeToLocate1);      System.Xml.XPath.XPathNodeIterator xpIter = xpNav.Select(xpExpression);     System.Collections.Hashtable ht = new System.Collections.Hashtable();      while (xpIter.MoveNext())     {         ht.Add('Location', xpIter.Current.Value);     }      xpExpression = xpNav.Compile(nodeToLocate2);      xpIter = xpNav.Select(xpExpression);     while (xpIter.MoveNext())     {         ht.Add('Weather', xpIter.Current.Value);     }      xpExpression = xpNav.Compile(nodeToLocate3);      xpIter = xpNav.Select(xpExpression);     while (xpIter.MoveNext())     {         ht.Add('Icon', xpIter.Current.Value);     }      return ht; } 
  • 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. 2026-05-10T22:24:18+00:00Added an answer on May 10, 2026 at 10:24 pm

    XmlTextReader cannot be reset to the beginning. Download you content first and then use multiple XmlTextReaders (if you have to).

    If the document you are downloading is small, I would just use an XmlDocument (or XDocument if you are using .NET 3.5)

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

Sidebar

Related Questions

Another easy one hopefully. Let's say I have a collection like this: List<DateTime> allDates;
Another basic Rails question: I have a database table that needs to contain references
In another question, Mark speaks highly of IDEs, saying some people still just dont
I have had the problem described in the question Tiling rectangles seamlessly in WPF
I have a WPF window that has TopMost=true . When I call another Window
Another poster asked about preferred syntax for infinite loops . A follow-up question: Why
Another question asked about determining odd/evenness in C, and the idiomatic (x & 1)
In another question I posted yesterday, I got very good advice on how a
In another question on SO I answered with code like the one below and
Another slightly non-technical question, but I couldn't decide whether to ask here or on

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.