Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8747963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:26:43+00:00 2026-06-13T12:26:43+00:00

the example of reference var x1:XML = <x1> <a id = 52>AYY</a> <a>AYY 2

  • 0

the example of reference

var x1:XML = <x1>
                <a id = "52">AYY</a>
                <a>AYY 2 </a>
                <b>BEE</b>
                <c>CEE</c>
            </x1>;

trace(x1.toXMLString());
trace("___________");

delete x1.a.@id;

trace(x1.toXMLString());
trace("___________");

delete x1.b;

trace(x1.toXMLString());
trace("___________");

delete x1.a;

trace(x1.toXMLString());

output

<x1>
  <a id="52">AYY</a>
  <a>AYY 2</a>
  <b>BEE</b>
  <c>CEE</c>
</x1>
___________
<x1>
  <a>AYY</a>
  <a>AYY 2</a>
  <b>BEE</b>
  <c>CEE</c>
</x1>
___________
<x1>
  <a>AYY</a>
  <a>AYY 2</a>
  <c>CEE</c>
</x1>
___________
<x1>
  <c>CEE</c>
</x1>

what if i only want to delete one element? or i want to delete the element which is and has no child element?

i can only use delete x1.a. ridiculous! i spend hours and couldn’t find a simple way .

var list:XMLList = x1.elements('a');
for each(var x:XML in list){
    if(....){
        //make something done
        //i want to delete this x from the xml object.while keep other node untouched.
    }
}

let me know the way you handle with this problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:26:44+00:00Added an answer on June 13, 2026 at 12:26 pm

    Its easy… take a look:

    var x1:XML = <x1>
                     <a id = "52">AYY</a>
                     <a>AYY 2 </a>
                     <b>BEE</b>
                     <c>CEE</c>
                 </x1>;
    
    trace(x1.toXMLString() + "\n");
    
    var nodesToDelete:XMLList = x1.a;
    
    trace(nodesToDelete.toXMLString() + "\n");
    
    delete nodesToDelete[0];
    
    trace(x1.toXMLString() + "\n");
    

    Output:

    <x1>
      <a id="52">AYY</a>
      <a>AYY 2</a>
      <b>BEE</b>
      <c>CEE</c>
    </x1>
    
    <a id="52">AYY</a>
    <a>AYY 2</a>
    
    <x1>
      <a>AYY 2</a>
      <b>BEE</b>
      <c>CEE</c>
    </x1>
    

    And you can even do this:

    delete x1.a[0];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I ran an example copied from: http://developers.facebook.com/docs/reference/javascript/ http://developers.facebook.com/docs/reference/javascript/FB.api/ (I only changed my APP_ID) <div
I'm trying to pass document.write as a reference to a variable: Example: var f
i can reference link with specific id with following code $(document).ready(function(){ $(a#example_link_id).click(function(event){ var url
for example: [{ data: reference, attr: { id: 0 }, state: open, children: [
In the example section of the @OneToMany JPA annotation reference : Example 1-59 @OneToMany
I can't think of an example where the reference count of a file may
Code as reference: http://jsbin.com/aboca3/2/edit In this example above (thank you SLaks) I am truncating
Can you pass by reference with R ? for example, in the following code:
As an example, I'm trying to add a reference to WatiN in Visual Studio
How should I correctly reference protocols on a UML class diagram? For example my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.