Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does this XML query not work?
    text
    copied!<p>Heres some code for a test case. I don't understand why the first two queries produce a result but the third one doesn't. Any ideas?</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="onInit();" &gt; &lt;mx:Script&gt; &lt;![CDATA[ private function onInit():void{ var someXML:XML = &lt;libs&gt; &lt;library libLevel="System"&gt; &lt;type typeName="Established Problem" typeID="2"&gt; &lt;template templateName="asthma" templateAbbr="asthma-fu" templateInsertDate="05/03/2004" templateID="14"/&gt; &lt;template templateName="gastroesophageal reflux" templateAbbr="GERD" templateInsertDate="05/03/2004" templateID="15"/&gt; &lt;/type&gt; &lt;/library&gt; &lt;/libs&gt;; trace("library"); trace(someXML.library.(@libLevel == "System"));//works as expected trace("type"); trace(someXML.library.type.(@typeID == "2"));//works as expected trace("template"); trace(someXML.library.type.template.(@templateID == "14"));//returns nothing } ]]&gt; &lt;/mx:Script&gt; &lt;/mx:Application&gt; </code></pre> <p>What does work is if I add a dummy node below the one that doesn't query right.</p> <pre><code>var someXML:XML = &lt;libs&gt; &lt;library libLevel="System"&gt; &lt;type typeName="Established Problem" typeID="2"&gt; &lt;template templateName="asthma" templateAbbr="asthma-fu" templateInsertDate="05/03/2004" templateID="14"&gt; &lt;blah/&gt; &lt;/template&gt; &lt;template templateName="gastroesophageal reflux" templateAbbr="GERD" templateInsertDate="05/03/2004" templateID="15"&gt; &lt;blah/&gt; &lt;/template&gt; &lt;/type&gt; &lt;/library&gt; &lt;/libs&gt;; </code></pre> <p>Why does it only work if there is a node below it?</p>
 

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