PDA

View Full Version : Ext.DomQuery doesn't work with a certain query



Wilky
13 Apr 2012, 1:02 AM
Hi there,
I've got some problems to query an xml document with Ext.DomQuery class.
The query is: '//el[not(subel)]'

And this is the XML:



<?xml version="1.0"?>
<doc>
<el id="1">
<name>foo</name>
</el>
<el id="2">
<subel href="1"/>
<name>bar</name>
</el>
<el id="3">
<subel href="2"/>
<name>foobar</name>
</el>
</doc>


And that's the code:



Ext.Ajax.request ({
url: 'http://localhost/doc.xml' ,
success: function (res) {
var xml = res.responseXML;
var dq = Ext.DomQuery;
var el = dq.select ('//el[not(subel)]', xml);
// Here we got an infinite loop ...
}
});


As you can see, the execution goes in an infinite loop but the result should be like this:



<el id="1">
<name>foo</name>
</el>


I tried with a simple xpath processor, giving the same query and file, and it works!

Maybe Ext.DomQuery.select() expects a different query with the same mean?

Thanks in advance.

Wilk

Wilky
13 Apr 2012, 4:07 AM
Ok, I found the solution by myself.
This is the right query: dq.select ('el:not(el:has(subel))', xml);

It selects those elements that does not match with those that have subel as a descendant.

Ciao!

Wilk