Note that there are some explanatory texts on larger screens.

plurals
  1. POUse SimpleXml in php to add additional data into element and save
    primarykey
    data
    text
    <p>I am using simplexml to load an API URL in the form of an XML through php. In the <code>ProductDescription</code> element it contains html that I would like to append onto in the warranty section. I would like to add <code>&lt;li&gt;Valid in US&lt;/li&gt;</code> in the <code>ProductDescription</code> element before the LAST <code>&lt;/ul&gt;</code> tag:</p> <pre><code> &lt;xmldata&gt; &lt;Products&gt; &lt;ProductCode&gt;ACODE&lt;/ProductCode&gt; &lt;ProductID&gt;1234&lt;/ProductID&gt; &lt;ProductName&gt;PRODUCTTITLE&lt;/ProductName&gt; &lt;ProductDescription&gt; &lt;h1&gt;Stuff&lt;/h1&gt;&lt;p&gt;description&lt;/p&gt;&lt;hr /&gt;&lt;strong&gt;Features &amp;amp; Benefits&lt;/strong&gt; &lt;ul&gt;&lt;li&gt;feat&lt;/li&gt;&lt;li&gt;feat&lt;/li&gt;&lt;li&gt;feat&lt;/li&gt;&lt;/ul&gt;&lt;hr /&gt;&lt;strong&gt;Specifications&lt;/strong&gt;&lt;ul&gt;&lt;li&gt;spec&lt;/li&gt;&lt;li&gt;spec&lt;/li&gt;&lt;li&gt;spec&lt;/li&gt;&lt;/ul&gt; &lt;hr /&gt;&lt;strong&gt;Warranty Information for a certain product&lt;/strong&gt; &lt;ul&gt;&lt;li&gt;3 Years Parts&lt;/li&gt;&lt;li&gt;3 Years Labor&lt;/li&gt;&lt;/ul&gt;&lt;div&gt; &lt;a href="/ahref" target="_blank"&gt;See more products from MFG &lt;/a&gt;&lt;/div&gt; &lt;/ProductDescription&gt; &lt;ProductManufacturer&gt;MFG&lt;/ProductManufacturer&gt; &lt;/Products&gt; &lt;/xmldata&gt; </code></pre> <p>Now all I can do is get the bare code out of the ProductDescription, I need to know of a way to add that <code>list</code> tag to end of the last <code>ul</code> tag before posting or displaying. Here is my partial php:</p> <pre><code> foreach( $xml as $NEW_XML ) { $code = $NEW_XML-&gt;ProductCode; $name = $NEW_XML-&gt;ProductName; $desc = $NEW_XML-&gt;ProductDescription; $mfg = $NEW_XML-&gt;ProductManufacturer; echo "&lt;textarea rows='13' cols='64' name='DESC' /&gt;" . $desc. "&lt;/textarea&gt;"; } </code></pre> <p>I am hoping I dont have to use REGex as it could be a pain (unless someone knows of a way). My inital thoughts would be to put it into a <code>&lt;textarea&gt;</code> and simply posting it back to an xml, but if there is a way to get to save as an .xml directly that would be more effiecient.</p>
    singulars
    1. This table or related slice is empty.
    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