Note that there are some explanatory texts on larger screens.

plurals
  1. POFind value in XML and output it
    primarykey
    data
    text
    <p>I have this XML</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; &lt;uclassify xmlns="http://api.uclassify.com/1/ResponseSchema" version="1.01"&gt; &lt;status success="true" statusCode="2000"/&gt; &lt;readCalls&gt; &lt;classify id="cls1"&gt; &lt;classification textCoverage="1"&gt; &lt;class className="female" p="0.932408"/&gt; &lt;class className="male" p="0.0675915"/&gt; &lt;/classification&gt; &lt;/classify&gt; &lt;/readCalls&gt; &lt;/uclassify&gt; </code></pre> <p>or similar. What matters is, I don't have </p> <pre><code>&lt;tag&gt;value&lt;/tag&gt; </code></pre> <p>but </p> <pre><code>&lt;tag attribute1 attribute2 ... /&gt;. </code></pre> <p>What I want to output is for instance </p> <blockquote> <p>attribute1: attributevalue1</p> </blockquote> <p>So I want to enter a term like "female" and I want it to output 0.932408.</p> <p>What I tried to get started</p> <pre><code>string xml = HttpGet("http://uclassify.com/browse/" + username + "/" + classifiername + "/" + operation + "?" + paramz.ToString()); XDocument doc = XDocument.Parse(xml); var list = doc.Root.Elements("uclassify") .Select(element =&gt; element.Value) .ToList(); </code></pre> <p>But list is always empty, which is presumably because there are no values, only attributes.</p> <p>EDIT:</p> <p>current version</p> <pre><code>string xml = HttpGet("http://uclassify.com/browse/" + username + "/" + classifiername + "/" + operation + "?" + paramz.ToString()); XDocument doc = XDocument.Parse(xml); XNamespace ns = "http://api.uclassify.com/1/ResponseSchema"; var list = doc.Root.Descendants(ns + "class") .Select(element =&gt; element.Value) .ToList(); textBox1.Text = string.Join(",", list.ToArray()); </code></pre> <p>Result is a comma.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload