Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-04-2012, 03:47 PM   PM User | #1
Rabel
New to the CF scene

 
Join Date: Jan 2012
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Rabel is an unknown quantity at this point
Editing the string that is passed to two different xml files

Hi Guys,
I am taking a form and updating two xml files with the information, but I need to slightly alter the info.
I need to add a piece of the url to the output.
I need to add this url to the beginning on the content info on the second xml file
http://mediasrv3.blahblah.net/arch/

I have tried a bunch of different codes but it just hasn't worked,
$media2->setAttribute('url', "http://mediasrv3.blahblah.net/arch/" + $_POST['content']);
or
$media2->createTextNode('http://mediasrv3.blahblah.net/arch/'+ $_POST['content'])

The input data in the form comes in and looks like this
videos/hd/2185/36kil1vntk5uvq4auh1p4z7jbsl6e530.mp4

in the file
loadAndEdit.xml
the data that is being added should stay the same
videos/hd/2185/36kil1vntk5uvq4auh1p4z7jbsl6e530.mp4

in the file
loadAndEdit-html.xml
the data should add
http://mediasrv3.blahblah.net/arch/
to the beginning of the output, so it would equal
http://mediasrv3.blahblah.net/arch/vide ... l6e530.mp4

Thanks for the help.
Randy



PHP Code:
/*if form to add an element has been submitted we write new item to the file*/
if (isset($_POST['submitAdd'])) {
    
$xml_fname "loadAndEdit.xml";
    
$xml = new DOMDocument();
    
$xml->load($xml_fname);
    
$root $xml->documentElement;
       
        
$xml2_fname "loadAndEdit-html.xml";
    
$xml2 = new DOMDocument();
    
$xml2->load($xml2_fname);
    
$root2 $xml2->documentElement;

    
$xpath = new DOMXPath($xml);
    
$xpath->registerNamespace('c''http://search.yahoo.com/mrss/');
       
        
$xpath2 = new DOMXPath($xml2);
    
$xpath2->registerNamespace('c''http://search.yahoo.com/mrss/');

    
$channel $xpath->query("//channel");
    
$item $xml->createElement('item');
    
$channel->item(0)->appendChild($item);
    
$elTitle $xml->createElement('title');
    
$item->appendChild($elTitle);
    
$elTitle->appendChild($xml->createTextNode($_POST['itemtitle']));
    
$media $xml->createElement('media:credit');
    
$item->appendChild($media);
    
$media->setAttribute('role''author');
    
$media->appendChild($xml->CreateTextNode($_POST['credit']));
    
$media $xml->createElement('media:content');
    
$item->appendChild($media);
    
$media->setAttribute('url'$_POST['content']);
    
$media $xml->createElement('media:thumbnail');
    
$item->appendChild($media);
    
$media->setAttribute('url'$_POST['thumbnail']);  
        
$elprov $xml->createElement('jwplayer:provider');
    
$item->appendChild($elprov);
    
$elprov->appendChild($xml->createTextNode('rtmp'));
        
$elstream $xml->createElement('jwplayer:streamer');
    
$item->appendChild($elstream);
    
$elstream->appendChild($xml->createTextNode('rtmp://mediasrv3.praizevision.net/aecarch')); 
    
$xml->formatOutput true;
    
$xml->save($xml_fname);
       
    
$channel2 $xpath2->query("//channel");
    
$item2 $xml2->createElement('item');
    
$channel2->item(0)->appendChild($item2);
    
$elTitle2 $xml2->createElement('title');
    
$item2->appendChild($elTitle2);
    
$elTitle2->appendChild($xml2->createTextNode($_POST['itemtitle']));
    
$media2 $xml2->createElement('media:credit');
    
$item2->appendChild($media2);
    
$media2->setAttribute('role''author');
    
$media2->appendChild($xml2->CreateTextNode($_POST['credit']));
    
$media2 $xml2->createElement('media:content');
    
$item2->appendChild($media2);
    
$media2->setAttribute('url'$_POST['content']);
    
$media2 $xml2->createElement('media:thumbnail');
    
$item2->appendChild($media2);
    
$media2->setAttribute('url'$_POST['thumbnail']);
       
    
$xml2->formatOutput true;
    
$xml2->save($xml2_fname);  

Rabel is offline   Reply With Quote
Old 01-04-2012, 04:57 PM   PM User | #2
Rabel
New to the CF scene

 
Join Date: Jan 2012
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Rabel is an unknown quantity at this point
this is the important line
$media2->setAttribute('url', $_POST['content']);

I just need to add
http://mediasrv3.blahblah.net/arch/
before the post content

Any Ideas?
Rabel is offline   Reply With Quote
Old 01-04-2012, 05:47 PM   PM User | #3
Spookster
Supreme Overlord


 
Spookster's Avatar
 
Join Date: May 2002
Location: Marion, IA USA
Posts: 6,224
Thanks: 4
Thanked 80 Times in 79 Posts
Spookster will become famous soon enough
If you want to concantenate it to the post content you need to use a .

$media2->setAttribute('url', 'http://mediasrv3.blahblah.net/arch/' . $_POST['content']);
__________________
Spookster
CodingForums Supreme Overlord
All Hail Spookster
Who gave you that Ugging infraction? Yeah that's right it was me!
Spookster is offline   Reply With Quote
Users who have thanked Spookster for this post:
Rabel (01-04-2012)
Old 01-04-2012, 06:02 PM   PM User | #4
Rabel
New to the CF scene

 
Join Date: Jan 2012
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Rabel is an unknown quantity at this point
Thanks Spookster, i just needed to change + to .

Thanks again
Randy
Rabel is offline   Reply With Quote
Reply

Bookmarks

Tags
cms, php

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:13 AM.


Advertisement
Log in to turn off these ads.