Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    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);  


  • #2
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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?

  • #3
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    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

  • Users who have thanked Spookster for this post:

    Rabel (01-04-2012)

  • #4
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks Spookster, i just needed to change + to .

    Thanks again
    Randy


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •