I have an XML feed that looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<productFeed version="1.0" timestamp="20100910:04:06:55">
<product id="196">
<name>Lorem</name>
<price>190.00</price>
<description>Lorem Ipsum</description>
<productURL> http://www.example.com</productURL>
<imageURL> http://www.exam...
This is starting to piss me off real bad. I have this XML code:
Updated with correct namespaces
<?xml version="1.0" encoding="utf-8"?>
<Infringement xsi:schemaLocation="http://www.movielabs.com/ACNS http://www.movielabs.com/ACNS/ACNS2v1.xsd" xmlns="http://www.movielabs.com/ACNS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&g...
After an xPath, I'm left with this var_dump:
array(1) {
[0]=>
object(SimpleXMLElement)#2 (1) {
[0]=>
string(11) "22-99586795"
}
}
echoing the damn thing only gives me "Array()"
How do I get the bloody string out?
Thanks
...
This is my RSS template that I load into my simplexml object. I want to change the
<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<atom:link href="link" rel="self" type="application/rss+xml" />
<title></title>
<link></link>
<description><...
$xml = simplexml_load_file($xmlPath);
$items = $xml->list->item;
...
echo $items[$currentIndex]->asXML();
When I print out $currentIndex on each iteration, I get 0, 1, 2, 3, 4, etc.
When I hard code $items[0]->asXML(); $items[1]->asXML(); $items[2]->asXML(); etc. I get the data I want.
But when I loop like I do in the first code segme...
After learning how to "correctly" unset a node, I noticed that using PHP's unset() function leaves the tabs and spaces behind. So now I have this big chunk of white space in between nodes at times. I'm wondering if PHP iterates through blank spaces/returns/tabs and whether it would eventually slow down the system.
I'm also asking whethe...
I'm working on a class extending SimpleXMLElement:
class MyXML extends SimpleXMLElement {
public function cdata($text) {
$node = dom_import_simplexml($this);
$owner = $node->ownerDocument;
$node->appendChild($owner->createCDATASection($text));
return $this;
}
}
Since it's an SimpleXMLElement, I ...
Hi!
I try to use SimpleXML in combination with XPath to find nodes which contain a certain string.
<?php
$xhtml = <<<EOC
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
<head>
<meta http-e...
Currently I have:
$content = ($propXml->xpath('//content/section[@name="accommodations"]/content'));
$content = is_array($content) && (count($content)>0)?(string)$content[0]:false;
echo $content;
Is there a more succinct way of doing this? It would be shorter if PHP had the ability to automatically access an assigned array, but I hav...
Hi all,
Could someone please help me out with this.
I need to find the gml:pos namespace in the xml.
But, very important! - in the $item part off the loop
I really have no clue how to get this done.
The namespace is in another custom namespace according to google-api docs.
$feed = simplexml_load_string($feedXml);
foreach ($feed->en...
<?php
$twitter_url = 'http://twitter.com/statuses/user_timeline/ishrikrishna.xml?count=1';
$buffer = file_get_contents($twitter_url);
$xml = new SimpleXMLElement($buffer);
$status = $xml -> status;
$tweet = $status -> text;
echo $tweet;
?>
I used this code to fetch tweets and it works successfully on localhost but not on my ...
I'm trying to edit some xml data. After this I want to save the data to file.
The problem is that the edited data isn't saved by simplexml but the node has changed.
$spieler = $xml->xpath("/planer/spieltag[@datum='" .$_GET['date']. "']/spielerliste/spieler");
for ( $i = 1; $i < 13; $i++ ){
if (!empty($_POST['spieler' .$i ])){
...
hi very good, I have a label on a form select and I get that value with $ _POST like this:
$gallery = array($_POST['gallery']);
and that value will put it here:
$image = $sitemap->gallery[$gallery]->addChild('image');
the problem is giving me error is as follows:
Fatal error: Call to a member function addChild() on a non-object in...
Hi,
I am trying to find an easy way to parse an eXist response with php without installing third party classes.
This is the type of response that I would like to parse :
<exist:result xmlns:exist="http://exist.sourceforge.net/NS/exist">
<exist:collection name="xData" path="/db/SBXXX/00000000-00000000/sapData" created="2010-07-15T...
I want to alter the class attribute of an image tag in PHP. I could do it using regex but want to use DOM / SimpleXML. The simplexml element looks like this:
$obj = simplexml_load_string($unprocessedfield);
var_dump($obj->img);
object(SimpleXMLElement)#108 (1) {
["@attributes"]=> array(6) {
["class"]=> string(33) "alig...
If I want to convert my PHP application to ASP.NET… what do you recommend and why?
I'm currently using PHP's simplexml_load_string() method because it's, well, …simple.
For example, for PHP to process an http request in the form of XML I just use:
$FILERAWDATA = file_get_contents("php://input");
$xml = simplexml_load_string($FILERAW...
<?xml version="1.0" encoding="utf-8"?><items>
<item><title>title3</title><desc>This is some desc3</desc></item></items>
There is no line break between each node element when using asXML() to output?
how to make output the file well-structured by adding link break
<?xml version="1.0" encoding="utf-8"?>
<items>
<item>
<title>title3</ti...
I have searched stackoverflow on this problem and did find a few topics, but I feel like there isn't really a solid answer for me on this.
I have a form that users submit and the field's value is stored in a XML file. The XML is set to be encoded with UTF-8.
Every now and then a user will copy/paste text from somewhere and that's when ...
I got a problem reading an XML-Feed
Sample of the XML File:
<f:feed xmlns:f="http://www.bbgo.de/feedxml/feed" xmlns:a="http://www.bbgo.de/feedxml/article" xmlns="http://www.w3.org/1999/xhtml" f:customer="blub" f:name="dax-tecdax">
<f:title>Analysen: DAX, TecDAX</f:title>
<f:date>2010-09-22T20:46:29+02:00</f:date>
<f:url>http://www.bbgo....
Sample XML:
<root>
<ratings>3</ratings>
<ratings>5</ratings>
<ratings>7</ratings>
</root>
The following code is the basis for my small application, it works as would be expected:
<?php
// $xml is some simplexml object
sizeof($xml->ratings); //3
foreach($xml->ratings as $rating){
echo($rating->value."::"); //thi...