Jump to content

updating using dom


myitalan

Recommended Posts

Greetings,

 

I thought I was done.. I had this part working first but now that i fixed the read part... the write part broke. Please help!! i am trying to update or (delete a record based on title) from the xml. 

 

here is the form:

<form action="processForm.php" method="post">

<fieldset>

<label for="title">Title:</label> <input type="text" id="title" name="title"/><br />

<label for="description">Description:</label><input type="text" id="description" name="description" /><br />

 

<select name="action">

<option value="ins">Insert</option>

<option value="del">Delete</option>

</select>

<input type="submit" />

</fieldset>

</form>

 

................................

 

and here is the php:

 

<?

 

$doc = new DOMDocument();

 

$doc->load( 'playlist.xml' );

 

 

$r = $doc->getElementsByTagName("gallery")->item(0);

 

$b = $doc->createElement("images");

 

$title = $doc->createElement("title");

$title->appendChild(

    $doc->createTextNode( $imges["title"] )

);

$b->appendChild( $title );

 

$description = $doc->createElement("description");

$description->appendChild(

    $doc->createTextNode( $imges["description"] )

);

$b->appendChild( $description );

 

$tmb = $doc->createElement("tmb");

$tmb->appendChild(

    $doc->createTextNode( $imges["tmb"] )

);

$b->appendChild( $tmb );

 

$img = $doc->createElement("img");

$img->appendChild(

    $doc->createTextNode( $imges["img"] )

);

$b->appendChild( $img );

 

$r->appendChild( $b );

 

$doc->save("playlist.xml");

....................

 

a couple of things: 

- I only have to input filelds in the form : title, description as the img and tmb is preloaded. 

 

Please help.

Link to comment
Share on other sites

i seem to really have difficult request or being new to coding I'm not getting my request across.  If you view this post please at least help me to know which it is.

 

If it's too difficult, please point me to a simpler way or if you don't understand, state so then I could retry.

 

Thanks for all your help.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.