0

First of all, sorry if this question is already answered, but i haven't found it.

I have an XML file that looks like this:

<data success="1" status="200">
    <id>SbBGk</id>
    <title/>
    <description/>
    <datetime>1341533193</datetime>
    <type>image/jpeg</type>
    <animated>false</animated>
    <width>2559</width>
    <height>1439</height>
    <size>521916</size>
    <views>1</views>
    <bandwidth>521916</bandwidth>
    <deletehash>eYZd3NNJHsbreD1</deletehash>
    <section/>
    <link>http://i.imgur.com/SbBGk.jpg</link>
</data>

I want to get the id as a string. Any ideas?

Note: The XML file is a web response, that i retrieve using:

XmlDocument doc = new XmlDocument();
byte[] response = w.UploadValues("https://api.imgur.com/3/upload.xml", values);
string xml = Encoding.UTF8.GetString(response);
doc.LoadXml(xml);
5

1 Answer 1

0

Instead of using XMLDocument, use XDocument.

XDocument doc = new XDocument();
doc.Load(xml);
string id = doc.Root.Element("id").Value;
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.