updatin xml in php -
Hello every one I have an XML file and I want to update my code
< Code> & lt; Gallerylist & gt; & Lt; Record & gt; & Lt; Film & gt; Video / 15Avatar_HD.flv & lt; / Film & gt; & Lt; Title & gt; Avatar1 & lt; / Title & gt; & Lt; Desc & gt; It runs any video file that supports Flash Player & lt; / Desc> & Lt; Preview & gt; Video / Preview / 6avatar.jpg & lt; / Preview & gt; & Lt; Imgplaylist & gt; Video / imgplaylist / 14p1.jpg & lt; / Imgplaylist & gt; & Lt; Category & gt; Action & lt; / Category & gt; & Lt; / Record & gt; & Lt; / Gallerylist & gt;
and my php function is as follows:
function xml_update_video ($ id, $ searchString) {$ res = $ this- & gt; Selection Video ($ id); $ SearchString = $ searchString; $ Doc = new DOMDocument; $ Doc- & gt; FormatOutput = TRUE; $ Doc- & gt; Protected WhiteSpace = FALSE; $ Doctor & gt; Load ('../playlist.xml'); $ XPath = new DOMXPath ($ doc); $ Query = sprintf ('// record [./ title [text () = "% s"]]', $ searchString); Forex Currency ($ xPath- & gt; Query ($ query) as $ node) {$ node- & gt; ParentNode-> Remove holes ($ node); } $ Gallerylist = $ doc- & gt; GetElementsByTagName ("Gallery List") - & gt; Item (0); $ Record = $ gallerylist- & gt; Append-Chilled ($ doc- & gt; Create element ('record')); $ Movie = $ record-> Append-Chilled ($ doc- & gt; Create Element ('Movie')); $ Movie- & gt; AppendChild ($ Doctor & gt; createTextNode ('video /' .$ race ['videofile'])); $ Title = $ record-> Append-Chilled ($ doc- & gt; Create element ('title')); $ TITLE-> AppendChild ($ Doctor & gt; createTextNode ($ race ['title']); $ Desc = $ record-> Append Chilled ($ doc- & gt; Create element ('desc')); $ Desc-> AppendChild ($ Doctor & gt; createTextNode ($ race ['description']); $ Preview = $ record- & gt; Append Chald ($ doc- & gt; Create element ('preview')); $ Preview- & gt; AppendChild ($ Doctor & gt; createTextNode ('video / preview' '.$ race [' previewImage '])); $ Imgplaylist = $ record-> Append-Chilled ($ doc- & gt; Create Element ('IMGPllist')); $ Imgplaylist- & gt; AppendChild ($ Doctor & gt; createTextNode ('video / imgplaylist /' .$ race ['playlistImage'])); $ Range = $ record-> Append Chilled ($ doc- & gt; Create element ('category')); $ Range & gt; AppendChild ($ Doctor & gt; createTextNode ($ race ['category'])); $ Doc- & gt; FormatOutput = true; $ Test1 = $ doc- & gt; Save XML (); $ Doctor & gt; Save ('../ playlist.xml'); }
The ID of the video file in the $ id database. With the help of ID I am adding the node to the new node in the x-m file which is based on the search criteria which is the title. This code is not working properly. This new node adds
this file adds a new node. Which is not correct, how should this update be the current node? Anyone can help
Notice what you said
< P> Add this file node. Which is not right. This should be the update current node
what you're actually doing
id with the new one Adding node is the title of the delete node based on the search string after . This code is not working properly. This adds a new node.
Of course this adds a new node to see your code. First you remove the node and then you are creating and adding new nodes. If you want to change the data of the node, do not delete it, but work with its properties, e.g. nodeValue
But how?
Sorry, I'm too lazy, busy and tired to write another long DOM, for example, please bear with me if I only link to you.
Comments
Post a Comment