Hi,
I'm trying to automatically update an existing rss podcast file using
php and the str_replace function.
Every time I add a media file, it should read the .rss file into a
string, take the closing </channel> and </rss> tags out of it, and add
the new rss file info to the end of the existing string, writing it
back to the rss file. However, str_replace will not replace the
</channel> and </rss> tags with ' '. I'm new to php, any help would be
appreciated.
Start Code:
----------------
$xmlFile = "/home2/kingshar/public_html/podcast_test.rs s";
$xmlReadHandle = fopen($xmlFile, 'r') or die("Cannot open podcast
file");
$xmlFileContent s = fread($xmlReadH andle, filesize($xmlFi le));
fclose($xmlFile );
//Search and delete closing rss tag
str_replace('</rss>', '', $xmlFileContent s);
//Search and delete closing channel tag
str_replace('</channel>', '', $xmlFileContent s);
//Write existing data and new data to xml file
$newxmlFileCont ents = $xmlFileContent s.
"\n<title>".$st itle."</title>\n<itunes :author>Author' s
Name</itunes:author>\ n<description>" .$scripture."</description>\n< pubDate>".$stor e_sdate."</pubDate>\n<gui
isPermaLink=fal se>".$audioFile ."</guid>\n<enclosu re url=".$audioFil e .
$audioSize ."type=audio/mpeg
/>\n<itunes:expl icit>clean</itunes:explicit >\n</item>\n\n</channel>\n</rss>";
$xmlWriteHandle = fopen($xmlFile, 'w') or die("Cannot open podcast
file");
fwrite($xmlWrit eHandle, $newxmlFileCont ents);
fclose($xmlFile ); 1 1678
Hello
Unless I'm missing something, I think the problem is that you are not
capturing the output of str_replace(). It does not modify the string
in-place; it returns the modified version of the string. So, instead
of:
str_replace('</rss>', '', $xmlFileContent s);
str_replace('</channel>', '', $xmlFileContent s);
do:
$xmlFileContent s = str_replace('</rss>', '', $xmlFileContent s);
$xmlFileContent s = str_replace('</channel>', '', $xmlFileContent s);
HTH
-Kurt ma**********@gm ail.com wrote: Hi,
I'm trying to automatically update an existing rss podcast file using php and the str_replace function. Every time I add a media file, it should read the .rss file into a string, take the closing </channel> and </rss> tags out of it, and add the new rss file info to the end of the existing string, writing it back to the rss file. However, str_replace will not replace the </channel> and </rss> tags with ' '. I'm new to php, any help would be appreciated.
Start Code: ---------------- $xmlFile = "/home2/kingshar/public_html/podcast_test.rs s"; $xmlReadHandle = fopen($xmlFile, 'r') or die("Cannot open podcast file"); $xmlFileContent s = fread($xmlReadH andle, filesize($xmlFi le)); fclose($xmlFile );
//Search and delete closing rss tag str_replace('</rss>', '', $xmlFileContent s); //Search and delete closing channel tag str_replace('</channel>', '', $xmlFileContent s); This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jon |
last post by:
Why does the following not replace the ":)"?
str_replace(":)", " <img
src=http://www.com.com/forum/emoticons/smiley.gif> ", $_POST);
But, the following does replace the ":("?
str_replace(":(", " <img
src=http://www.com.com/forum/emoticons/crying.gif> ", $_POST);
|
by: Hugo Coolens |
last post by:
I need to use the str_replace function for a php-script which works
together with html/javascript.
In the script I have to perform things like:
$arabic=str_replace ("'","\'", $row);
$arabic=str_replace ("sh", "\š", $row);
the second line works perfectly, however I can't make the first one
work, it should replace a single quote with a quote preceded by a
backslash. I presume I have to escape some characters to make this
happen however...
|
by: IWP506 |
last post by:
Hey all, I'm having some trouble. On a page, I've got a multiline text
box. When I enter :
a
b
c
d
and hit submit (sending to my post.php page) and from post.php, echo
$_POST if shows up as a b c d. No carrige returns show. My
|
by: Roco3D |
last post by:
I have an array with numbers from a excel file in 12345,78 format and y
need to change the coma (,) for a point (.) to make this numbers float.
I have this:
str_replace(",",".",$array_with_numbers); but does not work.
Any help???
|
by: Wayne |
last post by:
$a = $_POST; # txt_content = This is a<CR><LF>Test
$p = str_replace ("%0D%0A", "<br>", $a);
That is the above code that I am using, however, it is not picking up
the CR/LF from the textarea. I have also attempted singular variations
of the CR/LF combination and even reversed the sequence without success.
Is it possible that it may be encoded differently and if so what is it?
Thanks
| |
by: The Numerator |
last post by:
I have this page (print.php). In that file, I want to to include a text
file from "songs/breathe.txt", and replace all instances of "<b" with
"<span" and "</b>" with "</span>". I know how I should use str_replace
and I tried to do this:
<?php
$replace_a=str_replace("<span","<b",include("text/breathe.txt"));
$replace_b=str_replace("</span>",</b>",$replace_a);
|
by: jmark |
last post by:
I saw this example in php.net
// Outputs: apearpearle pear
$letters = array('a', 'p');
$fruit = array('apple', 'pear');
$text = 'a p';
$output = str_replace($letters, $fruit, $text);
echo $output;
and I am bit puzzled why the output is the way it is instead of
|
by: Smiley |
last post by:
I'm fooling around with using Eval and trying to manipulate a few things. I
ran into a couple of weird results. First of all, in one place I used the
following code:
$filestring = str_replace("<?", "\n<?\n", $filestring);
$filestring = str_replace("?>", "\n?>\n", $filestring);
Not a huge thing, just making things easier to read for me. But doing this
gives me an error, even when I comment those lines out. I have to remove
them...
|
by: bizt |
last post by:
Hi,
I am performing an XSLT on a XML feed. The XSLT produces me with PHP
code that I eval then insert into my DB. However, the way that the
system Im assigned to is setup, I need to convert all instances of
comma ',' to entity ',' .. so this requires that the output of the
XSLT needs to produce ',' but instead it converts it to a comma
which the current system doesnt like when handling it.
Below shows a snippet of what I have. What is...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |