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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:18:40+00:00 2026-05-23T11:18:40+00:00

Can anybody suggest a good and stable class to encode and decode XML in

  • 0

Can anybody suggest a good and stable class to encode and decode XML in PHP?

edit

found this example on php.net, but can’t make it work.. no error msgs is returned

$sxe = new SimpleXMLElement();
$sxe->addAttribute('type', 'documentary');

$movie = $sxe->addChild('movie');
$movie->addChild('title', 'PHP2: More Parser Stories');
$movie->addChild('plot', 'This is all about the people who make it work.');

$characters = $movie->addChild('characters');
$character  = $characters->addChild('character');
$character->addChild('name', 'Mr. Parser');
$character->addChild('actor', 'John Doe');

$rating = $movie->addChild('rating', '5');
$rating->addAttribute('type', 'stars');

echo $sxe->asXML();
  • 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-23T11:18:41+00:00Added an answer on May 23, 2026 at 11:18 am

    SimpleXML would probably be the easiest. Example:

    <root>
       <node>
          <sub>Text</sub>
       </node>
    </root>
    

     

    $xml = new SimpleXMLElement('xml_file.xml', 0, true);
    echo $xml->node->sub; // Displays "Text"
    

    Edit:

    In response to your code that isn’t working, you need to include a root node in the initiation of the class:

    $sxe = new SimpleXMLElement('<root />');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anybody suggest a good method for creating a facebook share implementation for my
Can anybody suggest some good resource/book on Database high availability techniques? Moreover, High-availability of
Please can anybody suggest me a good free facebook iFrames application which can allow
Could anybody suggest a good open source (as in I can see the source,
Can anybody suggest programming examples that illustrate recursive functions? For example fibonacci series or
Can anybody suggest a good codec for real-time video compression? Here is a list
Can anybody suggest any reasons why a C# timer (created in a code-behind class)
Hello can anybody solve this please I'm creating the object in the action class
Can anybody suggest me a good documentation tools with easy use GUI for C#
can anybody suggest me how can I achieve this 1) in camera mode I

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.