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

SimpleXML to get specific data from an XML file

I am making a plugin for JomSocial that will display billing information for a logged-in user, based on an XML file. I have made good headway creating the plugin, I just cant seem to get the syntax right to create php statements so I can populate…
1
vote
1 answer

Simplexml_load_string() does not load indexes

I am reading a XML file that has the following content:
1
vote
1 answer

Overriding SimpleXMLElement::__toString and casting to string

I have some XML that I want to read into a SimpleXMLElement, the element values are then used as strings by casting the elements to string. For each SimpleXMLELement I'd like to change the element string before returning it. Rather than repeating…
dsas
  • 1,650
  • 18
  • 30
1
vote
1 answer

I'm getting empty object attribute when i use simplexml_load_string

When I'm trying to use simplexml_load_string it returns an array of "SIMPLE XML objects" with some "Empty" object attributes. Actually those attributes are not empty in the real XML output! Do you have any suggestions? $url =…
Ibraheem
  • 160
  • 1
  • 11
1
vote
2 answers

how to use the sum-function in xpath?

There's the sum-function in xpath: 1 3 4 Now with SimpleXml... var_dump($xml->xpath("sum(/list/a)")); delivers NULL instead of 8 What's wrong here? see it not working: https://eval.in/135558 EDIT:…
michi
  • 6,565
  • 4
  • 33
  • 56
1
vote
3 answers

Adding up the TOTAL number of XML Items with PHP

I am trying to get the total number of bikes available in a bike share system. I am using php and simpleXML to filter the XML data. I have successfully retrieved the number of bikes at each station. foreach ($xml->station as $items) { print…
1
vote
3 answers

In SimpleXML, can I access a field based on an attribute directly?

I'm using SimpleXML to go through a kml doc, and I'm working on a project where I need to retrieve attributes in a specific order. If I had something like…
John Sly
  • 763
  • 1
  • 10
  • 31
1
vote
1 answer

Can't access XML node via xpath() (YT channel feed)

Very stumped by this one. In PHP, I'm fetching a YouTube user's vids feed and trying to access the nodes, like so: $url = 'http://gdata.youtube.com/feeds/api/users/HCAFCOfficial/uploads'; $xml = simplexml_load_file($url); So far, so fine. Really…
Mitya
  • 33,629
  • 9
  • 60
  • 107
1
vote
1 answer

Extra data in simplexml using namespaces

I am trying to learn XML in php but there is something I dont understand when using namespaces. This is my code $xml_data = new SimpleXMLElement(""); $make =…
Sinnbeck
  • 617
  • 4
  • 20
  • 56
1
vote
2 answers

Display ♥ correctly in php

I am using php to dynamically display a page. However, it does not display correctly on some characters, for example ♥. I am getting the JSON string using SimpleXML. When I do echo $string, it returns âÂÂ¥. Then, I tried using utf8_decode($string),…
faeophyta
  • 323
  • 5
  • 16
1
vote
1 answer

Iteration with SimpleXML foreach loop - import matrix

I trying to make a simple matrix for parsing XML files with quite different tags, i doing it with simple table viz. screen, table has primary and foreign atribute, in primary are main tag in foreign are quite similiar tags, so basicly i have code,…
1
vote
1 answer

How to retrieve value from SimpleXMLElement Object

After calling the prestashop webservice, I recieved the response as shown below: SimpleXMLElement Object ( [order] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array …
lomse
  • 4,045
  • 6
  • 47
  • 68
1
vote
2 answers

PHP SimpleXML DOM using between functions

I have been trying to get my head around how simplexml and dom updates XML between functions. The reason i ask is that the code i have written seems to work, but without me having to declare anything as global, and im a little confused as to why it…
Peter John
  • 1,859
  • 4
  • 15
  • 14
1
vote
2 answers

Extract a value from a property in camel-context.xml

The input looks like below, 123 XYZ I have set the above in property in an xml route as:
SAM
  • 49
  • 1
  • 11
1
vote
1 answer

PHP Simple XML to get Nodes based on their attribute

I have created an XML file that has a structured list of franchises. Problem is that I want to grab a franchise by it's id without having to iterate throughout the whole list. This is how I can get the attributes of the first franchise. But I want…
SMKS
  • 179
  • 1
  • 4
  • 13
1 2 3
99
100