Parsing XML from string C#

I am trying to deserialize a string, response.Content, with this XML

<?xml version="1.0" encoding="utf-8"?><root><uri><![CDATA[]]></uri><stations><station><name>12th St. Oakland City Center</name><abbr>12TH</abbr><gtfs_latitude>37.803664</gtfs_latitude><gtfs_longitude>-122.271604</gtfs_longitude><address>1245 Broadway</address><city>Oakland</city><county>alameda</county><state>CA</state><zipcode>94612</zipcode></station>

I am using this code to deserialize it:

var serializer = new XmlSerializer(typeof(Stations), new XmlRootAttribute("root"));
Stations result;
using (TextReader reader = new StringReader(response.Content))
    result = (Stations)serializer.Deserialize(reader);

I then have the Stations class declared here

public class Stations

    public string name;


However, my name is null. Any idea why?

Source: xml

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.