I can't speak for javascript as I'm not the expert here, but in a lot of
other languages you have to explicitly tell objects and functions that the
String you are using is xml, else its just a string, which sounds like your
problem here.

cheers

Michael Lawson
Development Lead, Global Solutions, ibm.com
Phone:  1-276-206-8393
E-mail:  mjlaw...@us.ibm.com

'Examine my teachings critically, as a gold assayer would test gold. If you
find they make sense, conform to your experience, and don't harm yourself
or others, only then should you accept them.'


                                                                       
  From:       bigb <bryanands...@gmail.com>                            
                                                                       
  To:         "jQuery (English)" <jquery-en@googlegroups.com>          
                                                                       
  Date:       06/23/2009 11:39 AM                                      
                                                                       
  Subject:    [jQuery] XML manipulation                                
                                                                       






I'm having some real difficulty figuring out how to manipulate xml
data with jquery. Here is my situation. I have a hidden TextArea that
contains xml data, something like this:

<items>
  <item value='1' text='x'></item>
  <item value='2' text='y'></item>
</items>


So, let's say I want to remove the item with value='1'.

1) I grab the value of the textarea:

    var xml = $("#" + id).val();

2) I then find the node and remove it:

    $(xml).find("item[value='123']").remove();


Problem is, it doesn't remove anything! It finds the node just fine,
but the remove() function doesn't seem like it is doing anything. I've
tried looping through eacy item $('item',xml).each(function.... ); and
then calling remove(); but that does not work either. Any help on how
to manipulate xml data correctly? Thank you.

Bryan

<<inline: graycol.gif>>

<<inline: ecblank.gif>>

Reply via email to