Hi:

I'm a noob, so please be kind.

I am using jquery to parse some xml.  I'm looking for the best
practice to access an elements text contents.

Let's say my xml looks like this:

<items>
  <item>
     Hello world!
   </item
   <item>
      Goodnight moon!
   </item>
<items>

I can get a wrapped set of the elements this way: $('items > item',
xml)

And I can get the text of element 1 this way:  $('items > item:eq(1)',
xml).text()

But how do I get the contents once I am directly accessing the element
instead of the jquery object?

In other words I'd like to do something like this: $('items > item',
xml)[1].text(), but since the element that’s returned from the array
[] doesn’t support text() how do I get it’s contents?

I know I can wrap it in a second $ call, as in $($('items > item', xml)
[1]).text() but that seems less than ideal.

Thanks!

Reply via email to