Note that there are some explanatory texts on larger screens.

plurals
  1. POSelecting values from a DOM / XML using Jquery selectors
    primarykey
    data
    text
    <p>I have a following structered DOM result, getting after a POST event:</p> <pre><code>&lt;root&gt; &lt;config&gt; // Some inner tree &lt;/config&gt; &lt;test&gt; &lt;test testValue="0"&gt; &lt;id&gt;90&lt;/id&gt; &lt;time&gt;false&lt;/time&gt; &lt;config&gt; &lt;config1&gt;1&lt;/config1&gt; &lt;/config&gt; &lt;languages&gt; &lt;language id="en" isDefault="true" &gt; &lt;test22 text="" /&gt; &lt;test23 text="" /&gt; &lt;/language&gt; &lt;/languages&gt; &lt;answers&gt; &lt;answer&gt; &lt;id&gt;201&lt;/id&gt; &lt;Texts&gt; &lt;Text localeId="en" Text="Yes" /&gt; &lt;/Texts&gt; &lt;/answer&gt; &lt;answer&gt; &lt;id&gt;202&lt;/id&gt; &lt;Texts&gt; &lt;Text localeId="en"Text="No" /&gt; &lt;/Texts&gt; &lt;/answer&gt; &lt;/answers&gt; &lt;/test&gt; &lt;/test&gt; &lt;/root&gt; </code></pre> <p>The above DOM returns after calling $.get(url, function(XML)), and I am able to do these:</p> <p>Getting the Text (Yes, No), and id (201, 202) with the following code.</p> <pre><code> $(XML).find("answer").each(function(){ var textValue = $(this).find("Text").attr("Text"); var idValue = $(this).find("id").text(); }); </code></pre> <p>But I couldn't find the correct combination to get id (90) e.g. following didn't work:</p> <pre><code>$(XML).find("test").children().attr("id"); </code></pre> <p>It's quite frustrating to debug jquery. I installed Firefox addon, Firequery, and saved the DOM into a file with html extension, but Firequery didn't allow me to chain the functions like $.find("id").text(); . What is the way to get the id value 90 from DOM with jquery? What are you using to debug the jquery while working with DOM and XML files like in the snippet?</p>
    singulars
    1. This table or related slice is empty.
    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.
    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