PHP forum

SimpleXML parsing need help

Feb 11, 2010 5:20 pm
Alejandro

So I just don't get it.

here is a part of the xml code:
......
<weather>
<date>2010-02-11</date>
<tempMaxC>4</tempMaxC>
<tempMaxF>40</tempMaxF>
........

i can get the date with
echo " date",$xml->weather[0]->date;

so how comes that i can't get

echo " max temperatura ",$xml->weather[0]->tempMaxC;

Feb 11, 2010 5:38 pm
Michael Fesser
Re: simpleXML parsing need help

.oO(alejandro)

>So I just don't get it.
>
>here is a part of the xml code:
>......
><weather>
><date>2010-02-11</date>
><tempMaxC>4</tempMaxC>
><tempMaxF>40</tempMaxF>
>........
>
>i can get the date with
>echo " date",$xml->weather[0]->date;
>
>so how comes that i can't get
>
>echo " max temperatura ",$xml->weather[0]->tempMaxC;

The usual questions: What happens? Any error messages (make sure your
error reporting is configured properly)? Can you post a short, but
complete XML and some PHP that shows the problem?

Micha


Feb 11, 2010 7:48 pm
Doug Miller
Re: simpleXML parsing need help

In article <hl1e9v$714$1@ss408.t-com.hr>, "alejandro" <aleksandar27@BRISIOVOnet.hr> wrote:
>So I just don't get it.
>
>here is a part of the xml code:
>.......
><weather>
><date>2010-02-11</date>
><tempMaxC>4</tempMaxC>
><tempMaxF>40</tempMaxF>
>.........
>
>i can get the date with
>echo " date",$xml->weather[0]->date;
>
>so how comes that i can't get
>
>echo " max temperatura ",$xml->weather[0]->tempMaxC;

What happens when you try?


Feb 11, 2010 11:17 pm
Alejandro
Re: simpleXML parsing need help

Hmmm.... sorry don't know what happened the formatting in the post has gone
and now it is even a bigger mess...






Previous Thread: Enhancing my search? very new to php
Next Thread: Manually close connection

Related Forum Topics
Simplexml puzzle
I am calling the google maps geocode APIs to retrieve address
information. The call returns an xml structure. I am using simplexml
to decode it and work with it. Here's the relevant code segment:

$data = curl_exec($ch); //retrieve data
curl_close($ch); //close curl
$xml =...
Simplexml - remove item
Hi,

I have a tree parsed with SimpleXML, and now I want to remove one item from
the list of objects and re-write the file. How do I drop one?

--
------------------------------------
Gernot Frisch
http://www.glbasic.com



SimpleXml select element by attribute value
Hi.

I'm trying to use simpleXml to parse a KML file and save some of the
KML data to a MySQL database.

I want to select a 'Style' element that has an attribute 'id' equal to
my PHP variable '$styleUrl.

A snippet of the KML to show how the Style elements are structured:

<Document>
...
Simplexml -> assign node value will destroy object

Hi,

how can I change the value of an XML node?

echo htmlspecialchars( $xentry->asXML() ); // OK, fine
$xentry['XDATA'] = $_POST['text']; // works perfectly

// ERROR IS HERE
$xentry = $_POST['heading']; // try to change "getName" value

echo htmlspecialchars($xentry->asXML()); //...
Simplexml adding 'encoding' attribute to xml declaration
I'm creating an xml file using simplexml, but would like to add the encoding="UTF-8" to the XML declaration. Like this:

<?xml version="1.0" encoding="UTF-8"?>

How can I do this?

Here's my code:

<?php
$namesXML = new SimpleXMLElement("<names></names>");
echo...
How can I add itunes rss xmlns namespace definition to a php simplexml document?
I'm trying to create an itunes-valid podcast feed using php5's
simplexml. Here's what I have so far:

<?php
$xml_string = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<channel>
</channel>
XML;
$xml_generator = new SimpleXMLElement($xml_string);
...
Parsing Error
Hello,

I'm getting :

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE,
expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/l/a/
n/lanmind/html/lanmindphp.php on line 60

Line 60:

mysql_query("UPDATE answers SET answer= '$userinput' WHERE...
XML parsing problem


Hello Guys,

I have a problem related to XML parsing , I am sending some XML data
in soap envelope using php .

The response I get is given below

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope...
Need help with JSON parsing with PHP
I have a script that generates a *very long* JSON string and then
(tries to) parse it with PHP using json_decode().

Unfortunately, json_decode is returning false. I am running PHP
5.2.8.

phpinfo() tells me:

json support enabled
json version 1.2.1

Upgrading to PHP 5.3.0 is not an...
Issue with a xml parsing
Hi there. Anyone capable of telling me WHY I just get 3 data outputs
from the feed in my code below?


<?php

// read xml file into string
$text = file_get_contents("http://ads-cdn.unibet.com/orval/feed/
PokerTournaments.xml");

if(!$text) {
die("ERROR: Unable to read file");
}

//...