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

  • Home
  • SEARCH
  • 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 546229
In Process

The Archive Base Latest Questions

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

It looks like there are many problems with simpleXML in PHP. I’m running the

  • 0

It looks like there are many problems with simpleXML in PHP. I’m running the latest version of php on Windows and I just can not get the basic examples of simpleXML to work as in the documentation.

My xml file is:

<?xml version="1.0" encoding="ISO-8859-1"?>
<programme> 
  <title>Billy Bushwaka</title> 
  <episodeNumber>2</episodeNumber> 
  <description>Billy Bushwaka entertains</description> 
  <url>play.swf</url> 
</programme> 

My PHP program is:

<?php
$xml = simplexml_load_file("local.xml");

$result = $xml->xpath("//programme");
echo "Title: " . $result . "</br>";
?>

All I get is the following:

Title: Array

How can I get “Title: Billy Bushwaka”?

There are no repeats of XML data so I do not want to use arrays.

  • 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-13T10:50:42+00:00Added an answer on May 13, 2026 at 10:50 am

    SimpleXML 101

    1. First of all, always name your PHP variables after the node they represent.

      // the root node is <programme/>
      $programme = simplexml_load_file("local.xml");
      
    2. Access to children (nodes) as if they were object properties.

      echo $programme->title;
      
    3. If there are multiple children using the same name, you can specify their 0-based position

      // first <title/> child
      echo $programme->title[0];
      
      // create or change the value of the second <title/> child
      $programme->title[1] = 'Second title';
      
    4. Access to attributes as if they were array keys

      // <mynode attr="attribute value" />
      echo $mynode['attr'];
      
    5. XPath always returns an array.


    Back to your case, the best way to access that <title /> node would be

    $programme = simplexml_load_file("local.xml");
    echo "Title: " . $programme->title;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 322k
  • Answers 322k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Don't know about any plugins but this shouldn't be too… May 14, 2026 at 12:47 am
  • Editorial Team
    Editorial Team added an answer Check the JNLP file syntax. You can use a j2se… May 14, 2026 at 12:47 am
  • Editorial Team
    Editorial Team added an answer Try using live jQuery('#sIMG img').live("click",function(){ }); As of jQuery 1.7,… May 14, 2026 at 12:47 am

Related Questions

I'm onto problem 245 now but have hit some problems. I've done some work
This question is a spin-off/evolution of this question . (That question got marked as
Lately, I'v been struggling with an annoying situation on ASP.NET MVC. Here's the story
Never asked a question here before, I'll try to lay this out as succinctly
I am running into a design disagreement with a co-worker and would like people's

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.