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

Exception thrown String could not be parsed as XML

I'm using this code channel->item as…
user3386034
  • 55
  • 2
  • 7
1
vote
1 answer

integrate as class library in codeigniter

I need to integrate the code that is in the answer to this thread. How to rotate SVG by PHP When I do it as a library I get error "construct", I do not have much knowledge about it, I hope you can help me.
1
vote
4 answers

PHP / JavaScript: how to pass array from PHP to JavaScript

I use the following PHP lines to convert some simpleXML data to an array: $dataRaw = array(); foreach($objCount->escalations as $esc) { $dataRaw[(string)$esc->region] = (int)$esc->volume; } $dataPrep = json_decode(json_encode($dataRaw),…
user2571510
  • 11,167
  • 39
  • 92
  • 138
1
vote
2 answers

XML Split Node on . value

I've used SO for many years and always found an answer but this time I have got myself well and truly lost. I have an xml file I would like to split the compatbility into well formed…
1
vote
1 answer

Iterate through xml file that has a php extension

I have been given an XML feed to get data from to use on a clients website, I have worked with XML before when the file is somfile.xml and for this I use simplexml_load_file, however the feed I have been given to work with is…
Rik89
  • 157
  • 4
  • 22
1
vote
1 answer

multiple child in nodes in php simplexml-displaying only first item

I have the following xml file and i am using php simplexml to parse the data: 2014-06-09 http://www.myproducts.com Wireless Bluetooth Speaker -…
user3737431
  • 49
  • 10
1
vote
1 answer

How to save a neatly formatted XML file using Simple XML?

What's the "trick" to save an XML file that visually would result neatly formatted? such as: foo and not: foo
cesko80
  • 147
  • 1
  • 1
  • 9
1
vote
1 answer

XML to PHP array to mysql

I'm trying to import a xml data from a google xml document using simple xml to achieve that, an example of the code is here tag:google.com,2013:googlealerts/feed:11187837211342886856 …</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/php" class="post-tag grid--cell" title="show questions tagged 'php'" rel="tag">php</a> <a href="../../questions/tagged/xml" class="post-tag grid--cell" title="show questions tagged 'xml'" rel="tag">xml</a> <a href="../../questions/tagged/simplexml" class="post-tag grid--cell" title="show questions tagged 'simplexml'" rel="tag">simplexml</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jun 15 '14 at 17:13">asked Jun 15 '14 at 17:13</time> <a href="../../users/3482036/user3482036" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/3482036.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="user3482036" /> </a> <div class="s-user-card--info"> <a href="../../users/3482036/user3482036" class="s-user-card--link">user3482036</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">109</li> <li class="s-award-bling s-award-bling__bronze" title="11 bronze badges">11</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-24158266"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>1</strong></span> <div class="viewcount">vote</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/24158266/how-to-get-values-of-child-node-from-rdf-file-using-xpath-php" class="question-hyperlink">How to get values of child node from RDF file using xpath PHP</a></h3> <div class="excerpt">my question here is how can i get the child nodes from a RDF file using xpath. here you can see these set of nodes used multiple times: <?xml version="1.0" encoding="utf-8"?> <rdf:RDF xml:base="http://www.gutenberg.org/" …</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/php" class="post-tag grid--cell" title="show questions tagged 'php'" rel="tag">php</a> <a href="../../questions/tagged/xpath" class="post-tag grid--cell" title="show questions tagged 'xpath'" rel="tag">xpath</a> <a href="../../questions/tagged/simplexml" class="post-tag grid--cell" title="show questions tagged 'simplexml'" rel="tag">simplexml</a> <a href="../../questions/tagged/rdf" class="post-tag grid--cell" title="show questions tagged 'rdf'" rel="tag">rdf</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jun 11 '14 at 08:36">asked Jun 11 '14 at 08:36</time> <a href="../../users/3714281/adfsadasdsad" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/3714281.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="adfsadasdsad" /> </a> <div class="s-user-card--info"> <a href="../../users/3714281/adfsadasdsad" class="s-user-card--link">adfsadasdsad</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">29</li> <li class="s-award-bling s-award-bling__bronze" title="7 bronze badges">7</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-24148503"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>1</strong></span> <div class="viewcount">vote</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/24148503/get-value-of-xml-node" class="question-hyperlink">Get Value of XML Node</a></h3> <div class="excerpt">I am traversing through an xml file. I successfully read through all the nodes but when i try to access the value of that attribute, it returns empty object. If I run the following code $xml_data=simplexml_load_file($path .…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/xml" class="post-tag grid--cell" title="show questions tagged 'xml'" rel="tag">xml</a> <a href="../../questions/tagged/simplexml" class="post-tag grid--cell" title="show questions tagged 'simplexml'" rel="tag">simplexml</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jun 10 '14 at 18:37">asked Jun 10 '14 at 18:37</time> <a href="../../users/2489591/omicans" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/2489591.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Omicans" /> </a> <div class="s-user-card--info"> <a href="../../users/2489591/omicans" class="s-user-card--link">Omicans</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">531</li> <li class="s-award-bling s-award-bling__gold" title="1 gold badge">1</li> <li class="s-award-bling s-award-bling__silver" title="8 silver badge">8</li> <li class="s-award-bling s-award-bling__bronze" title="26 bronze badge">26</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-24108129"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>1</strong></span> <div class="viewcount">vote</div> </div> </div> <div class="status "> <strong>0</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/24108129/working-with-xhtml-with-different-encodings-in-simplexml-via-dom" class="question-hyperlink">Working with XHTML with different encodings in SimpleXML (Via DOM)</a></h3> <div class="excerpt">I have been attempting to use SimpleXML to parse XHTML which has been captured through output buffering. To get there I used a DOM object as per some excellent suggestions given in another question. The simpleXML object is fired off to other…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/php" class="post-tag grid--cell" title="show questions tagged 'php'" rel="tag">php</a> <a href="../../questions/tagged/character-encoding" class="post-tag grid--cell" title="show questions tagged 'character-encoding'" rel="tag">character-encoding</a> <a href="../../questions/tagged/simplexml" class="post-tag grid--cell" title="show questions tagged 'simplexml'" rel="tag">simplexml</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jun 08 '14 at 16:14">asked Jun 08 '14 at 16:14</time> <a href="../../users/1499072/matthew-brown-aka-lord-matt" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/1499072.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Matthew Brown aka Lord Matt" /> </a> <div class="s-user-card--info"> <a href="../../users/1499072/matthew-brown-aka-lord-matt" class="s-user-card--link">Matthew Brown aka Lord Matt</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">2,298</li> <li class="s-award-bling s-award-bling__gold" title="1 gold badge">1</li> <li class="s-award-bling s-award-bling__silver" title="27 silver badge">27</li> <li class="s-award-bling s-award-bling__bronze" title="40 bronze badge">40</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-24046415"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>1</strong></span> <div class="viewcount">vote</div> </div> </div> <div class="status answered-accepted"> <strong>2</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/24046415/format-php-simplexml-file" class="question-hyperlink">Format PHP simpleXML file</a></h3> <div class="excerpt">Im creating simple PHP code to generate sitemap.xml file, but the problem is, that the file is unformatted. If the file was smaller, I could look at it in browser, but it has about 1,5 MB and Chrome just gives up while loading it (IE loads it and…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/php" class="post-tag grid--cell" title="show questions tagged 'php'" rel="tag">php</a> <a href="../../questions/tagged/xml" class="post-tag grid--cell" title="show questions tagged 'xml'" rel="tag">xml</a> <a href="../../questions/tagged/simplexml" class="post-tag grid--cell" title="show questions tagged 'simplexml'" rel="tag">simplexml</a> <a href="../../questions/tagged/domdocument" class="post-tag grid--cell" title="show questions tagged 'domdocument'" rel="tag">domdocument</a> <a href="../../questions/tagged/sitemap" class="post-tag grid--cell" title="show questions tagged 'sitemap'" rel="tag">sitemap</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jun 04 '14 at 19:55">asked Jun 04 '14 at 19:55</time> <a href="../../users/2228606/michaelokgb" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/2228606.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="MiChAeLoKGB" /> </a> <div class="s-user-card--info"> <a href="../../users/2228606/michaelokgb" class="s-user-card--link">MiChAeLoKGB</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">796</li> <li class="s-award-bling s-award-bling__silver" title="14 silver badges">14</li> <li class="s-award-bling s-award-bling__bronze" title="38 bronze badges">38</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-24041709"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>1</strong></span> <div class="viewcount">vote</div> </div> </div> <div class="status answered-accepted"> <strong>2</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/24041709/how-do-i-output-a-element-like-element-something-from-xml-in-php" class="question-hyperlink">How do I output a element like "element:something" from XML in PHP?</a></h3> <div class="excerpt">How do I do so? I want to output the "d:lots" element. Trying to output other elements that does not have the ":prefix" works... but not for those with that... Here is the XML file I have: <feed…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/php" class="post-tag grid--cell" title="show questions tagged 'php'" rel="tag">php</a> <a href="../../questions/tagged/xml" class="post-tag grid--cell" title="show questions tagged 'xml'" rel="tag">xml</a> <a href="../../questions/tagged/simplexml" class="post-tag grid--cell" title="show questions tagged 'simplexml'" rel="tag">simplexml</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jun 04 '14 at 15:35">asked Jun 04 '14 at 15:35</time> <a href="../../users/3034898/theroyalstudent" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/3034898.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="theroyalstudent" /> </a> <div class="s-user-card--info"> <a href="../../users/3034898/theroyalstudent" class="s-user-card--link">theroyalstudent</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">13</li> <li class="s-award-bling s-award-bling__bronze" title="4 bronze badges">4</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-23966607"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>1</strong></span> <div class="viewcount">vote</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/23966607/to-get-all-the-child-elements-names-and-their-values-of-a-xml-tag-using-php" class="question-hyperlink">To get all the child elements names and their values of a xml tag using php</a></h3> <div class="excerpt">I want to get all the child tag names and their values of a parent tag in a xml file using php . My xml file looks like following <Business> <Franchise>False</Franchise> </Business> <Building> …</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/php" class="post-tag grid--cell" title="show questions tagged 'php'" rel="tag">php</a> <a href="../../questions/tagged/xml" class="post-tag grid--cell" title="show questions tagged 'xml'" rel="tag">xml</a> <a href="../../questions/tagged/simplexml" class="post-tag grid--cell" title="show questions tagged 'simplexml'" rel="tag">simplexml</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked May 31 '14 at 05:11">asked May 31 '14 at 05:11</time> <a href="../../users/3422501/user3422501" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/3422501.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="user3422501" /> </a> <div class="s-user-card--info"> <a href="../../users/3422501/user3422501" class="s-user-card--link">user3422501</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">145</li> <li class="s-award-bling s-award-bling__gold" title="1 gold badge">1</li> <li class="s-award-bling s-award-bling__silver" title="5 silver badge">5</li> <li class="s-award-bling s-award-bling__bronze" title="14 bronze badge">14</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-23921559"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>1</strong></span> <div class="viewcount">vote</div> </div> </div> <div class="status answered-accepted"> <strong>2</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/23921559/simplexml-query" class="question-hyperlink">SimpleXML query</a></h3> <div class="excerpt">hi my xml has this structure <articles> <article> <title>
alfredopacino
  • 2,979
  • 9
  • 42
  • 68