I haven't really worked with XML before, but I can't see storing it in a textarea actually working.
As I understand your code you have this

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

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

into the var 'xml'

This is now stored as a string
As far as I know you cannot use find on a string

I don't think this method will work, as far as I know you need to pull in the 
xml through ajax, and define it's dataType as xml.
You could try something like this

|$(function() {
                $.ajax({
                        type: "GET",
                        url: "items.xml",
                        dataType: "xml",
                        success: function(xml) {
                                $(xml).find('|item[value='123']|').remove();
                        }
                });
});
|

Like I said though, I've not worked with XML before.

- Liam

bigb wrote:
I don't have an option to remove it from the textarea at the moment.
Is there a better way to storing and generating xml data on the fly?

On Jun 23, 8:41 am, Liam Potter <radioactiv...@gmail.com> wrote:
take it out of the textarea, right now it's not XML data but random text.

bigb wrote:
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

Reply via email to