louis w wrote:
> Please check out the code below. I am having a hard time getting the
> protortype selectors to be applied to this item. Hoping to avoid
> having to use childNodes to parse this data.
>
> var xml = '<data><status>OK</status></data>';
>
> var parser = new DOMParser();
> var doc = parser.parseFromString(xml, "text/xml");
>
> console.log(doc);
>
> // Errors
> console.log($(doc).documentElement.select('status'));
>
>
> I have seen this exact thing done with jQuery's find command.
Unfortunatelly Prototype.js extends only prototypes of HTMLElement, so
it does not work with XML, SVG and so on.
You might find that some, but not all functions of prototype will work
if you run them as:
Element.select(doc.documentElement, 'status');
If the function DOES NOT internally call $(another-element), then it
might work. But those are only few functions. I have not checked if
the Element#select is one of them.
Also, in the code above you use $(doc). This is an error, cause in
prototype.js $() function is intended to be used only on Elements or
Element's IDs. You are passing the Document as an argument. That wont
work.
You can just use doc.documentElement, as the 'documentElement'
property is a standard property and is available without use of
prototype.js. _If_ the document was HTML, you could try to use
$(doc.documentElement) on it and that should work, but I am not sure,
as I never tried that.
Anyway, you can try to use portions of prototype on XML documents, but
they are not guaranteed to work.
--
Best regards,
SWilk
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---