Questions tagged [simplexml]

A PHP extension shipped with the main source tree. The SimpleXML extension provides a very simple and easily usable toolset to convert XML to an object that can be processed with normal property selectors and array iterators. For the Java "Simple" XML framework, please use the [simple-framework] tag.

The SimpleXML extension provides a simple toolset to convert XML to an object that can be processed with normal property selectors and array iterators.

Once an XML document is converted, the object obtained will reference the root element of the document. The object's properties will reflect the child nodes and uses the same name as the nodes. This principle works recursively across the document.

3932 questions
1
vote
2 answers

How to access nodes with simplexml

I'm accessing the wikipedia api like so: http://en.wikipedia.org/w/api.php?action=query&prop=extracts&format=xml&exsentences=2&exlimit=10&exintro=&explaintext=&redirects=&generator=search&gsrsearch=France&gsrlimit=10 This gives me xml, which I'm…
Phil
  • 1,719
  • 6
  • 21
  • 36
1
vote
2 answers

How to parse RSS non-XML feed in PHP?

I've been parsing tons of RSS feeds using PHP's simplexml_load_file and it works like a charm. Now I'm trying to do the same for the RSS feed of the Financial Times. When I do... $rss = simplexml_load_file("http://www.ft.com/rss/world"); ... I get:…
TheBigDoubleA
  • 432
  • 2
  • 7
  • 26
1
vote
2 answers

Is there anything wrong with creating an XML feed this way?

This is a fragment of code from one of my projects, I have looked up ways to creating XML documents with php and found suggestions to use SimpleXMLElement or DOMDocument but is there anything wrong with the below approach? it seems much more…
ericsicons
  • 1,475
  • 3
  • 23
  • 38
1
vote
1 answer

parsing xml file using simplexml and create array with named keys(not numerical keys) using php

i had already created multidimensional array from parsed xml file using simplexml with numerical keys but i want them to be named keys instead of numbers . xml file is as below:
nohan
  • 235
  • 1
  • 4
  • 12
1
vote
2 answers

How can this xpath query (PHP) be more flexible?

I'm parsing an XHTML document using PHP's SimpleXML. I need to query a series of ul's in the document for a node containing a specific value, then find that node's parent's direct previous sibling... code will help explain! Given the following dummy…
Andrew
  • 3,332
  • 4
  • 31
  • 37
1
vote
1 answer

simplexml_load_file, curl and file_get_contents doesn't work on the server

So i have a problem that made me crazy :( when i use simplexml_load_file, curl or file_get in my local machine it works fine but when i moved on the server it doesn't work and i got the timeout error, this is my simple code : $res =…
Mohammadov
  • 595
  • 3
  • 13
  • 34
1
vote
1 answer

regex + replace character between tags using Notepad++

I think using regex to find/replace is my best option for this.. but I'll give an overview of what I'm trying to do in case there is some other advice/suggestions I have a FLAT (static) .xml file I am converting things over to use a database…
whispers
  • 962
  • 1
  • 22
  • 48
1
vote
1 answer

simplexml_load_file and $_SESSION

I have a problem using simplexml_load_file and session vars in PHP. So, I have 2 PHP files, one generates some XML and the other one reads it. The file that generates XML should read some $_SESSION vars, which had been set in the other, but it…
nico
  • 50,859
  • 17
  • 87
  • 112
1
vote
1 answer

SimpleXML SOAP response Namespace issues in PHP

I'm having a seemingly impossible time getting my head around simple XML and soap. I've read in a file to simple xml, and this is the result to show it's read in properly: echo $garages->asXML(); // result
Jon
  • 155
  • 7
1
vote
2 answers

PHP loop through XML nested loops without multiple foreach loops?

Is there a cleaner way to achieve this: The XML is: Brand Apple list
user2029890
  • 2,493
  • 6
  • 34
  • 65
1
vote
1 answer

SimpleXML namespaces and attributes

I have an xml that looks like this:
Vladimir Hraban
  • 3,543
  • 4
  • 26
  • 46
1
vote
1 answer

How can I properly parse a SimpleXML Object in PHP?

I'm using the CloudFusion class to get Amazon.com data and my code is simple: $items = $pas->item_search( "shoes", array( "ResponseGroup" => "Small", "SearchIndex" => "Blended" )); $items = $items->body->Items; echo "
";
print_r(…
Shamoon
  • 41,293
  • 91
  • 306
  • 570
1
vote
1 answer

Last.fm getting image from track.getinfo

I'm a bit of a newbie in PHP programming, and have been Googleing and trying for hours now to get this to work. However, I'm out of luck. Hopefully someone can help me :-) What I'm trying to do is to use the Last.FM API to get the cover image of a…
zorensen
  • 334
  • 4
  • 19
1
vote
0 answers

simplexml_load_file not working with variable but works with string

I am trying to connect to a CRM (Pardot). I have this to create the URL necessary to call the XML: //this will log in and print your API Key (good for 1 hour) to the console $rz_key = callPardotApi('https://pi.pardot.com/api/login/version/3',…
1
vote
4 answers

Why can't I select the desired node using this PHP Xpath expression?

Using PHP, SimpleXML and the xpath() function, I want to select a child node, starting from a certain point. Can you please help me? I know in this specific case I could use an expression starting with "//", but I want to learn the right way of…
Kerans
  • 115
  • 1
  • 17