Note that there are some explanatory texts on larger screens.

plurals
  1. POLINQ to XML: How to get to child nodes
    text
    copied!<p>I'm new to LINQ to XML and appreciate assistance with getting to child nodes. </p> <p>XML document:</p> <pre><code> &lt;schedule&gt; &lt;job&gt; &lt;name&gt;nativeJobExample&lt;/name&gt; &lt;group&gt;nativeJobExampleGroup&lt;/group&gt; &lt;description&gt;Sample job for Quartz Server&lt;/description&gt; &lt;job-type&gt;Quartz.Job.NativeJob, Quartz&lt;/job-type&gt; &lt;job-data-map&gt; &lt;entry&gt; &lt;key&gt;command&lt;/key&gt; &lt;value&gt;native_job_example.bat&lt;/value&gt; &lt;/entry&gt; &lt;entry&gt; &lt;key&gt;consumeStreams&lt;/key&gt; &lt;value&gt;true&lt;/value&gt; &lt;/entry&gt; &lt;/job-data-map&gt; &lt;/job&gt; &lt;trigger&gt; &lt;simple&gt; &lt;name&gt;nativeJobExampleSimpleTrigger&lt;/name&gt; &lt;group&gt;nativeJobExampleSimpleTriggerGroup&lt;/group&gt; &lt;description&gt;Simple trigger to simply fire sample job&lt;/description&gt; &lt;job-name&gt;nativeJobExample&lt;/job-name&gt; &lt;job-group&gt;nativeJobExampleGroup&lt;/job-group&gt; &lt;misfire-instruction&gt;SmartPolicy&lt;/misfire-instruction&gt; &lt;repeat-count&gt;5&lt;/repeat-count&gt; &lt;repeat-interval&gt;10000&lt;/repeat-interval&gt; &lt;/simple&gt; &lt;/trigger&gt; &lt;/schedule&gt; </code></pre> <p>I'm able to get to nodes like this:</p> <pre><code>XDocument document = XDocument.Load(@pmPathFileName); XElement root = document.Root; root.Elements("job").Where(e =&gt; e.Element("name").Value.Equals("nativeJobExample")). Select(e =&gt; e.Element("description")).Single().SetValue("wwww"); </code></pre> <p>The XML document contains multiple pairs of jobs and triggers.</p> <p>Two questions on how to update values:</p> <ol> <li><p>How do I get to job-data-map|entry|key|value?</p></li> <li><p>How do I get to trigger|simple|name|repeat-count?</p></li> </ol>
 

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