0

Currently I am trying to use Jon Skeet's method of parsing an XML webpage, however, this answer may be out of date and not the best way to do it in Xamarin.

public static IEnumerable<XElement> SimpleStreamAxis(string inputUrl, string elementName)
    {
        using (XmlReader reader = XmlReader.Create(inputUrl))
        {
            reader.MoveToContent();
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (reader.Name == elementName)
                    {
                        XElement el = XNode.ReadFrom(reader) as XElement;
                        if (el != null)
                        {
                            yield return el;
                        }
                    }
                }
            }
        }
    }

This request times out. Is this the best way to parse an XML webpage for Xamarin? If so, how do I fix the time out error that I am getting.

Community
  • 1
  • 1
jipot
  • 304
  • 3
  • 13
  • 34
  • What resource? How are you calling it? What is the time out – Glenn Ferrie Jul 27 '15 at 00:43
  • Make sure to figure out what you have problem with - reading the page or parsing. So can't help you with resources returning errors/timing out. Additionally please try to clarify your criteria for "better" so one can suggest "the best" method. – Alexei Levenkov Jul 27 '15 at 00:44

1 Answers1

2

Use htmlagilitypack to parse the document, and find the element through Xpath. if you want to download the webpage, you can use HttpClient module or htmlagilitypack's static methods

aspark
  • 340
  • 2
  • 7