Note that there are some explanatory texts on larger screens.

plurals
  1. POSimpleXML: Sort XML - Place XML Entries at the top
    primarykey
    data
    text
    <p>Im using SimpleXML to add new images childs for a slideshow tool on my website, the code is something like this:</p> <pre><code>$xml_toload = $_SERVER['DOCUMENT_ROOT']. '/xml/'.$country.'/compact.xml'; $xml = simplexml_load_file($xml_toload); //This line will load the XML file. $sxe = new SimpleXMLElement($xml-&gt;asXML()); //In this line it create a SimpleXMLElement object with the source of the XML file. //The following lines will add a new child and others child inside the previous child created. $image = $sxe-&gt;addChild('image'); $image-&gt;addAttribute('imageURL',$file); $image-&gt;addAttribute('thumbURL',$file); $image-&gt;addAttribute('linkURL',$linkurl); $image-&gt;addAttribute('linkTarget',$linkurl); $image-&gt;addChild('caption',$caption); $sxe-&gt;asXML($xml_toload); </code></pre> <p>Which is working perfectly to add the new <code>&lt;image attr="blabla"&gt;&lt;caption&gt;imageinfo&lt;/caption&gt;&lt;image&gt;</code> child, inside of <code>&lt;imagegallery&gt;&lt;/imagegalley&gt;</code></p> <p>But I have a serious problem, I need this childs to go just after <code>&lt;imagegallery&gt;</code>, not before the tag is closed, (one after other), this makes to appear new images, at the last place on the imagegallery slideshow.</p> <p>So the newest chids that I add, should go before the last it has added to the xml, like</p> <pre><code>&lt;imagegallery&gt; &lt;image attr="HEREGOESTHENEWST"&gt; &lt;caption&gt;description&lt;/caption&gt; &lt;/image&gt; &lt;image attr="THEOLDONE"&gt; &lt;caption&gt;description&lt;/caption&gt; &lt;/image&gt; &lt;/imagegallery&gt; </code></pre> <p>Anyone can help me with a clear example? Thank you, its urgent!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload