Note that there are some explanatory texts on larger screens.

plurals
  1. PODOM navigation: eliminating the text nodes
    primarykey
    data
    text
    <p>I have a js script that reads and parses XML. It obtains the XML from an XMLHttpRequest request (which contacts with a php script which returns XML). The script is supposed to receive 2 or more nodes under the first parentNode. The 2 nodes it requires have the name well defined, the other ones can be any name. The output from the php may be:</p> <pre><code>&lt;?xml version='1.0'?&gt; &lt;things&gt; &lt;carpet&gt; &lt;id&gt;1&lt;/id&gt; &lt;name&gt;1&lt;/name&gt; &lt;desc&gt;1.5&lt;/desc&gt; &lt;/carpet&gt; &lt;carpet&gt; &lt;id&gt;2&lt;/id&gt; &lt;name&gt;2&lt;/name&gt; &lt;height&gt;unknown&lt;/height&gt; &lt;/carpet&gt; &lt;/things&gt; </code></pre> <p>Here all carpets have 7 nodes.</p> <p>but it also may be:</p> <pre><code>&lt;?xml version='1.0'?&gt; &lt;things&gt; &lt;carpet&gt; &lt;id&gt;1&lt;/id&gt; &lt;name&gt;1&lt;/name&gt; &lt;desc&gt;1.5&lt;/desc&gt; &lt;/carpet&gt; &lt;carpet&gt;&lt;id&gt;2&lt;/id&gt;&lt;name&gt;2&lt;/name&gt;&lt;height&gt;unknown&lt;/height&gt;&lt;/carpet&gt; &lt;/things&gt; </code></pre> <p>Here the first carpet has 7 nodes, the 2nd carpet has 3 nodes. I want my javascript code to treat both exactly the same way in a quick and clean way. If possible, I'd like to remove all the text nodes between each tag. So a code like the one above would always be treated as:</p> <pre><code>&lt;?xml version='1.0'?&gt; &lt;things&gt;&lt;carpet&gt;&lt;id&gt;1&lt;/id&gt;&lt;name&gt;1&lt;/name&gt;&lt;desc&gt;1.5&lt;/desc&gt;&lt;/carpet&gt;&lt;carpet&gt;&lt;id&gt;2&lt;/id&gt;&lt;name&gt;2&lt;/name&gt;&lt;height&gt;unknown&lt;/height&gt;&lt;/carpet&gt;&lt;/things&gt; </code></pre> <p>Is that possible in a quick and efficient way? I'd like not to use any get function (getElementsByTagName(), getElementById, ...), if possible and if more efficient.</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.
    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