PDA

View Full Version : DomQuery selector using one of the its children nodeValue



glopes
23 May 2013, 6:01 AM
Hi,

I have a XML document called myXml that looks like this:


<Row>
<Proto>TCP</Proto>
<Date>2013-05-22T00:00:00</Date>
<Value>10</Value>
</Row>
<Row>
<Proto>UDP</Proto>
<Date>2013-05-22T00:00:00</Date>
<Value>5</Value>
</Row>
<Row>
<Proto>TCP</Proto>
<Date>2013-05-21T00:00:00</Date>
<Value>12</Value>
</Row>
<Row>
<Proto>UDP</Proto>
<Date>2013-05-21T00:00:00</Date>
<Value>5</Value>
</Row>

I want to know if there is a way to use Ext.DomQuery.select to get all the Rows where Proto=UDP.
What I've managed so far is to get the value of one sibling using:


var myValues = Ext.DomQuery.select('Proto:nodeValue(UDP) ~ Value', myXml);
var myDates = Ext.DomQuery.select('Proto:nodeValue(UDP) ~ Date', myXml);
What I really need is to select all Rows where Proto = UDP.

Thanks

slemmon
28 May 2013, 2:13 PM
This what you're looking for?


var selected = Ext.dom.Query.select('Row:has(Proto:nodeValue(UDP))');
console.log(selected);

glopes
28 May 2013, 2:35 PM
Perfect, thanks.