0

I have an xml file from weather icons that maps a string to an html encoded font string.

I have an xml file that looks something like

<?xml version="1.0" encoding="utf-8"?>
    <resources>
      <string name="wi_owm_200">&#xf01e;</string>
    </resources>

I need a way that I can lookup easily the string wi_omw_200 and get back

&#xf01e

is there an easy way to do this in c#?

1
  • Google XmlReader Commented Mar 8, 2017 at 2:33

1 Answer 1

2

You can use XmlNodeList

var xmlString = @"<?xml version=\"1.0\" encoding=\"utf-8\"?>
    <resources>
      <string name=\"wi_om_200w\">&#xf01e;</string>
    </resources>";

var xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xmlString); 

var xmlNodeList = xml.SelectNodes("/resources/string[@name='wi_om_200w']");
var value = xmlNodeList.FirstOrDefault();
if (value != null)
{
    Console.WriteLine(value.InnerText);
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.