1

I feel like I'm going crazy. I need to take a string of text from an xml file, and define it as a PHP variable and output it into an HTML page. I can't figure out why this wont work. Any ideas??

I have this xml document (people.xml):

<?xml version="1.0"?> <datas> <person> <people> <owner>Joe Blow</owner> </people> </person> </datas> 

This PHP (db.php):

<?php $xml = simplexml_load_file('people.xml') or die("Error: Can't load people"); $xml->person->people->owner = $owner; ?> 

This HTML(index.php):

<?php include 'db.php';?> <label for="owner-1"><?php echo $owner ?></label> 

1 Answer 1

2

Assuming everything else is right / Based on the code you have shown,

$xml->person->people->owner = $owner; 

should be

$owner = $xml->person->people->owner; 

You are trying to assign the value of $owner to $xml->person->people->owner It should be the other way round.

Sign up to request clarification or add additional context in comments.

2 Comments

10 seconds later...i was going to post the same xD
@RobertRozas Happens to me all the time :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.