# Update XML using PHP without uploading a File

**URL:** <https://forum.kirupa.com/t/update-xml-using-php-without-uploading-a-file/329467>\
**Category:** programming\
**Created:** [September 2, 2012, 12:44am UTC](https://forum.kirupa.com/t/update-xml-using-php-without-uploading-a-file/329467 "2012-09-02T00:44:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kasiris](https://avatars.discourse-cdn.com/v4/letter/k/e0b2c6/32.png) [@kasiris](https://forum.kirupa.com/u/kasiris)\
**Post date:** [September 2, 2012, 12:44am UTC](https://forum.kirupa.com/t/update-xml-using-php-without-uploading-a-file/329467/1 "2012-09-02T00:44:34Z")

</div>

# Hello All, here is my problem … for uploading Audio everything works like a charm, however when I attempt to update the xm for video “NOT HOSTED ON MY SERVER” the xml does not update. Here is my CODE:

# my.xml

# ?xml version=“1.0” encoding=“UTF-8” standalone=“yes”?\> \<feed\> \<!-- resultLength indicates the total number of results for this feed --\> \<resultLength\>12\</resultLength\> \<!-- endIndix indicates the number of results for this _paged_ section of the feed --\> \<endIndex\>12\</endIndex\> \<item sdImg=“[http://kasiris.comule.com/bladehd.jpg](http://kasiris.comule.com/bladehd.jpg)” hdImg=“[http://kasiris.comule.com/bladehd.jpg](http://kasiris.comule.com/bladehd.jpg)”\> \<title\>Boy Would You\</title\> \<contentId\>10001\</contentId\> \<contentType\>Music\</contentType\> \<contentQuality\>SD\</contentQuality\> \<streamFormat\>mp4\</streamFormat\> \<media\> \<streamQuality\>SD\</streamQuality\> \<streamBitrate\>1500\</streamBitrate\> \<streamUrl\>[http://kasiris.comule.com/bladeicewood\_boy\_would\_you.mp4](http://kasiris.comule.com/bladeicewood_boy_would_you.mp4)\</streamUrl\> \</media\> \<synopsis\>Owned by icewood ent/dirty glove ent rip icewood\</synopsis\> \<genres\>Rap\</genres\> \<runtime\>359\</runtime\> \</item\> \</feed\>

# uploadpage.php

\<h1\>Jukebox Playlist\</h1\>  
\<form action=“playlistaction.php” method=“post” enctype=“multipart/form-data”\>  
\<form name=“input” action=“html\_form\_action.asp” method=“get”\>  
Title…: \<input type=“text” name=“title” /\>\<br /\>  
Video Id: \<input type=“text” name=“contentId” /\>\<br /\>  
Type…: \<input type=“text” name=“contentType” /\>\<br /\>  
Quality…: \<input type=“text” name=“contentQuality” /\>\<br /\>  
Format…: \<input type=“text” name=“streamFormat” /\>\<br /\>  
Bitrate…: \<input type=“text” name=“streamBitrate” /\>\<br /\>  
Url…: \<input type=“text” name=“streamUrl” /\>\<br /\>  
Synopis…: \<input type=“text” name=“synopis” /\>\<br /\>  
Genres…: \<input type=“text” name=“genres” /\>\<br /\>  
Length…: \<input type=“text” name=“runtime” /\>\<br /\>  
\<input type=“submit” value=“Submit” /\>  
\</form\>  
\</fieldset\>  
\</form\>  
\<h2\>Current entries:\</h2\>  
\<p\>Title - VideoId - Type - Quality - Format - Bitrate - VideoUrl - Synopis - Genres - Length\</p\>  
\<?php  
$doc = new DOMDocument();  
$doc-\>load( ‘musiclist.xml’ );

$feed = $doc-\>getElementsByTagName( “item” );  
foreach( $feed as $item)  
{  
$titles = $item-\>getElementsByTagName( “title” );  
$title = $titles-\>item(0)-\>nodeValue;

$contentIds = $item-\>getElementsByTagName( “contentId” );  
$contentId = $contentIds-\>item(0)-\>nodeValue;

$contentTypes = $item-\>getElementsByTagName( “contentType” );  
$contentType = $contentTypes-\>item(0)-\>nodeValue;

$contentQualitys = $item-\>getElementsByTagName( “contentQuality” );  
$contentQuality = $contentQualitys-\>item(0)-\>nodeValue;

$streamFormats = $item-\>getElementsByTagName( “streamFormat” );  
$streamFormat = $streamFormats-\>item(0)-\>nodeValue;

$streamBitrates = $item-\>getElementsByTagName( “streamBitrate” );  
$streamBitrate = $streamBitrates-\>item(0)-\>nodeValue;

$streamUrls = $item-\>getElementsByTagName( “streamUrl” );  
$streamUrl = $streamUrls-\>item(0)-\>nodeValue;

$synopiss = $item-\>getElementsByTagName( “synopis” );  
$synopis = $synopiss-\>item(0)-\>nodeValue;

$genress = $item-\>getElementsByTagName( “genres” );  
$genres = $genress-\>item(0)-\>nodeValue;

$runtimes = $item-\>getElementsByTagName( “runtime” );  
$runtime = $runtimes-\>item(0)-\>nodeValue;

# echo “\<b\>$title - $contentId - $contentType - $contentQuality - $streamFormat - $streamBitrate - $streamUrl - $synopis - $genres - $runtime \</b\>\<br\>”; } ?\>

# playlistaction.php

\<?php  
$uploadDir = ‘songs/’;

if(isset($\_POST[‘upload’]))  
{  
$fileName = $\_FILES[‘userfile’][‘name’];  
$tmpName = $\_FILES[‘userfile’][‘tmp\_name’];  
$fileSize = $\_FILES[‘userfile’][‘size’];  
$fileType = $\_FILES[‘userfile’][‘type’];  
$filePath = $uploadDir . $fileName;

$result = move\_uploaded\_file($tmpName, $filePath);  
if (!$result) {  
echo “Error uploading file”;  
exit;  
}

}

$song = array(  
‘title’ =\> $\_POST[‘title’],  
‘contentId’ =\> $\_POST[‘contentId’],  
‘contentType’ =\> $\_POST[‘contentType’],  
‘contentQuality’ =\> $\_POST[‘contentQuality’],  
‘streamFormat’ =\> $\_POST[‘streamFormat’],  
‘streamBitrate’ =\> $\_POST[‘streamBitrate’],  
‘streamUrl’ =\> $\_POST[‘streamUrl’],  
‘synopis’ =\> $\_POST[‘synopis’],  
‘generes’ =\> $\_POST[‘generes’],  
‘runtime’ =\> $\_POST[‘runtime’],  
);

$doc = new DOMDocument();  
$doc-\>load( ‘musiclist.xml’ );

$doc-\>formatOutput = true;  
$r = $doc-\>getElementsByTagName(“feed”)-\>item(0);

$b = $doc-\>createElement(“itme”);

$title = $doc-\>createElement(“title”);  
$title-\>appendChild(  
$doc-\>createTextNode( $itme[“title”] )  
);  
$b-\>appendChild( $title );  
$contentId = $doc-\>createElement(“contentId”);  
$contentId-\>appendChild(  
$doc-\>createTextNode( $itme[“contentId”] )  
);  
$b-\>appendChild( $contentId );  
$contentType = $doc-\>createElement(“contentType”);  
$contentType-\>appendChild(  
$doc-\>createTextNode( $itme[“contentType”] )  
);  
$b-\>appendChild( $contentType );  
$contentQuality = $doc-\>createElement(“contentQuality”);  
$contentQuality-\>appendChild(  
$doc-\>createTextNode( $itme[“contentQuality”] )  
);  
$b-\>appendChild( $contentQuality );  
$streamFormat = $doc-\>createElement(“streamFormat”);  
$streamFormat-\>appendChild(  
$doc-\>createTextNode( $itme[“streamFormat”] )  
);  
$b-\>appendChild( $streamFormat );  
$streamQuality = $doc-\>createElement(“streamQuality”);  
$streamQuality-\>appendChild(  
$doc-\>createTextNode( $itme[“streamQuality”] )  
);  
$b-\>appendChild( $streamQuality );  
$streamBitrate = $doc-\>createElement(“streamBitrate”);  
$streamBitrate-\>appendChild(  
$doc-\>createTextNode( $itme[“streamBitrate”] )  
);  
$b-\>appendChild( $streamBitrate );  
$streamUrl = $doc-\>createElement(“streamUrl”);  
$streamUrl-\>appendChild(  
$doc-\>createTextNode( $itme[“streamUrl”] )  
);  
$b-\>appendChild( $streamUrl );

$synopis = $doc-\>createElement(“synopis”);  
$synopis-\>appendChild(  
$doc-\>createTextNode( $itme[“synopis”] )  
);  
$b-\>appendChild( $synopis );

$generes = $doc-\>createElement(“generes”);  
$generes-\>appendChild(  
$doc-\>createTextNode( $itme[“generes”] )  
);  
$b-\>appendChild( $generes );

$runtime = $doc-\>createElement(“runtime”);  
$runtime-\>appendChild(  
$doc-\>createTextNode( $itme[“runtime”] )  
);

$b-\>appendChild( $title );  
$b-\>appendChild( $contentId );  
$b-\>appendChild( $contentType );  
$b-\>appendChild( $contentQuality );  
$b-\>appendChild( $streamFormat );  
$b-\>appendChild( $streamBitrate );  
$b-\>appendChild( $streamUrl );  
$b-\>appendChild( $synopis );  
$b-\>appendChild( $generes );  
$b-\>appendChild( $runtime );

$doc-\>save(“musiclist.xml”);

```
header("Location: {$_SERVER['HTTP_REFERER']}");    

```

# ?\>

# The End

Please note that I don’t wish to upload any files just update the .xml file, all might not be accurate because I have been going back and forward :crying: but this is where I am stuck at ☹ (the xml is accuirate) I am not good with php so any help would be helpful =) Thank You in advance and I hope to get some assistance soon.
