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 565183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:50:43+00:00 2026-05-13T12:50:43+00:00

When I call addChild(‘actor’, ‘John Doe’); this child is added in the last. Is

  • 0

When I call

addChild('actor', 'John Doe');

this child is added in the last. Is there a way to make this new child a first child?

  • 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-05-13T12:50:43+00:00Added an answer on May 13, 2026 at 12:50 pm

    As it’s been mentionned, SimpleXML doesn’t support that so you’d have to use DOM. Here’s what I recommend: extend SimpleXMLElement with whatever you need to use in your programs. This way, you can keep all the DOM manipulation and other XML magic outside of your actual program. By keeping the two matters separate, you improve readability and maintainability.

    Here’s how to extend SimpleXMLElement with a new method prependChild():

    class my_node extends SimpleXMLElement
    {
        public function prependChild($name, $value)
        {
            $dom = dom_import_simplexml($this);
    
            $new = $dom->insertBefore(
                $dom->ownerDocument->createElement($name, $value),
                $dom->firstChild
            );
    
            return simplexml_import_dom($new, get_class($this));
        }
    }
    
    $actors = simplexml_load_string(
        '<actors>
            <actor>Al Pacino</actor>
            <actor>Zsa Zsa Gabor</actor>
        </actors>',
        'my_node'
    );
    
    $actors->addChild('actor', 'John Doe - last');
    $actors->prependChild('actor', 'John Doe - first');
    
    die($actors->asXML());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I call this a flash meeting, but maybe there is another more appropriate name.
Is there a way to detect when a child is removed from a DisplayObjectContainer?
Is there a way to call a function inside a loaded SWF file? Basically,
I call a function like this: call_facebook(103138046395999, samåkning.se, http://www.facebook.com/samakning, page); call_facebook(16089699074, Jag ska köra
I call this function from with my code-behind: DeleteFile(Server.MapPath(/) + sitemap_index.xml) Public Shared Function
I have a function in stage and need to call it from a child
I have the below function creating new panels inside my ViewStack.. This works fine
I'm new to ActionScript, so there is a possibility that I'm asking something simple.
I'm trying to call a function in one child class (Circle.as) from another child
I am encountering a problem with this addChild function I created (This function is

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.