PDA

View Full Version : searching capabilities in xml ?


frontline
07-21-2003, 09:21 AM
Hello
say i like to search attribute value in one of the node's what are the tools i have in xml/xsl/js (client side only)
that can give me the attribute value ?
for example i have :
------------------------------------------------------------------
<root>
<foo1 atr1="1" atr2="22" atr3="333">
<foo2 atr1="44" atr2="55" atr3="66">
</root>
-----------------------------------------------------------------
and i like to find all the <foo> nodes that have atr1="44"
or all the "atr1" that = 55 ... and so on...
thanks

Alex Vincent
07-21-2003, 07:32 PM
Currently there is no DOM standard procedure for getting elements by an attribute match. So, normally, you'd be out of luck.

However, I've a tutorial in the pipeline for JavaScriptKit.com which specifically details an Element.getElementsByAttrMatch() method. It should suit you nicely, depending on which browsers you are writing for.

E-mail me and I'll send you a couple drafts of the tutorial.

brothercake
07-21-2003, 08:42 PM
are you familiar with XSL? You can iterate through a set of nodes and then process only those with a given attribute value, or value range.

My XSL is not primo but I can probably whip up an example if you wanna go down that road?

frontline
07-22-2003, 07:06 AM
Hello
well i dont think xsl will help me here because i need the result to execute in real time by function call ( button onclick)
i do use now xsl to filter and to build html file from given xsl .
but i may be wrong .. i will look into "getElementsByAttrMatch() "
my browser is IE 5.5+ so i have lots of options to use ,i just dont know what.
thanks

frontline
07-22-2003, 07:31 AM
are you sure i can use this in IE ?
i can't find any ref in the msdn

brothercake
07-22-2003, 07:04 PM
What Alex mentioned doesn't exist as a built-in - it's a method he's designed as part of an article he's writing. Did you contact? he offered to give you the info.