| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Regular Join Date: Mar 2006
Posts: 887
![]() ![]() ![]() | Quick Find & Replace Question! Hi, I have a XML page here. Basically, I need to change the AA! (1) for every file to (2) all the way through to (2611). Is there any Find and Replace formula I could use, instead of doing this manually? Or, some simple PHP script I could incorperate into this XML page? I would hate to have to waste 5 hours editing these numbers... ![]() PHP Code:
__________________ http://www.twitter.com/chrisrwilliams -- mention you're a NP'er, and i'll follow you back immediately |
| | |
| | #2 (permalink) |
| Senior Member Join Date: Aug 2006 Location: Australia
Posts: 1,362
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | I'm half asleep so I may be missing something obvious but cant you just use the replace function of a text editor?
__________________ Dolphins OMFG! BeZazz [US/UK] Low Cost Friendly Hosting 33% Discount Coupon 33-NPS |
| | |
| | THREAD STARTER #3 (permalink) |
| NamePros Regular Join Date: Mar 2006
Posts: 887
![]() ![]() ![]() | Absolutely, but, I need to replace each number with a something different. So I would be using the replace function about 2600 times. Each (1) needs to be replaced with (2) then (3) then (4) etc
__________________ http://www.twitter.com/chrisrwilliams -- mention you're a NP'er, and i'll follow you back immediately |
| | |
| | #4 (permalink) |
| Senior Member Join Date: Aug 2006 Location: Australia
Posts: 1,362
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Ahh ok. If you haven't found the answer by tomorrow (currently 3:35am here) and still looking for a way to do it. I will write up some php for you. Just PM me if interested.
__________________ Dolphins OMFG! BeZazz [US/UK] Low Cost Friendly Hosting 33% Discount Coupon 33-NPS |
| | |
| | THREAD STARTER #5 (permalink) |
| NamePros Regular Join Date: Mar 2006
Posts: 887
![]() ![]() ![]() | Thanks, I really appreciate that
__________________ http://www.twitter.com/chrisrwilliams -- mention you're a NP'er, and i'll follow you back immediately |
| | |
| | #6 (permalink) |
| NamePros Regular Join Date: Jul 2007 Location: UK
Posts: 394
![]() ![]() ![]() ![]() ![]() ![]() ![]() | Code: <?xml version="1.0" encoding="UTF-8"?>
<simpleviewerGallery maxImageWidth="480" maxImageHeight="480" textColor="0xFFFFFF" frameColor="0xffffff" frameWidth="20" stagePadding="40" thumbnailColumns="3" thumbnailRows="3" navPosition="left" title="SimpleViewer Title" enableRightClickOpen="true" backgroundImagePath="" imagePath="" thumbPath="">
<?php
for ($i = 1; $i <= 2611; $i++)
{
echo '<image>
<filename>AA! ('.$i.').jpg</filename>
<caption>Free Avatars!/caption>
</image>
';
}
?>
</simpleviewerGallery> ????: NamePros.com http://www.namepros.com/showthread.php?t=580601 If you need to use a different file extension, you'll need to make a change to your .htaccess file to use the PHP interpreter. For example: Code: RemoveHandler .xml AddType application/x-httpd-php .xml
__________________ |
| | |
| | THREAD STARTER #7 (permalink) |
| NamePros Regular Join Date: Mar 2006
Posts: 887
![]() ![]() ![]() | Thanks so much! I'm going to try this right now. I will post back the results ![]() ---------- Post added at 02:16 PM ---------- Previous post was at 02:10 PM ---------- I edited gallery.xml with the code you wrote, and added the .htaccess in the root but it essentially acts as if there are no images in the gallery at all. I would only assume this is because of the whole PHP code being in an XML file
__________________ http://www.twitter.com/chrisrwilliams -- mention you're a NP'er, and i'll follow you back immediately |
| | |
| | #8 (permalink) |
| NamePros Regular Join Date: Jul 2007 Location: UK
Posts: 394
![]() ![]() ![]() ![]() ![]() ![]() ![]() | Is the XML file being processed by the web server? If not, rename the file so that it ends with .php, add the following to the beginning: Code: <?php header("Content-Type: plain/text"); ?>
__________________ |
| | |
| | #9 (permalink) |
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,074
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | qbert220 that is not going to work properly. For example on the 1st run $i is going to be 1, you will replace 1 with 2, on the 2nd run $i is going to be 2. Guess what is going to happen, the 1 you just replaced with 2 will now be replaced with 3. You should start with 2611 and work your way down instead.
__________________ Manage your portfolio using my new Domain Portfolio Management script. Securing Your Domain Name From Theft |
| | |
| | #10 (permalink) |
| NamePros Regular Join Date: Jul 2007 Location: UK
Posts: 394
![]() ![]() ![]() ![]() ![]() ![]() ![]() | Code: <?xml version="1.0" encoding="UTF-8"?>
<simpleviewerGallery maxImageWidth="480" maxImageHeight="480" textColor="0xFFFFFF" frameColor="0xffffff" frameWidth="20" stagePadding="40" thumbnailColumns="3" thumbnailRows="3" navPosition="left" title="SimpleViewer Title" enableRightClickOpen="true" backgroundImagePath="" imagePath="" thumbPath="">
<image>
<filename>AA! (1).jpg</filename>
<caption>Free Avatars!/caption>
</image>
<image>
<filename>AA! (2).jpg</filename>
<caption>Free Avatars!/caption>
</image>
<image>
<filename>AA! (3).jpg</filename>
<caption>Free Avatars!/caption>
</image>
<image>
<filename>AA! (4).jpg</filename>
<caption>Free Avatars!/caption>
</image>
...
<image>
<filename>AA! (2611).jpg</filename>
<caption>Free Avatars!/caption>
</image>
</simpleviewerGallery>
__________________ |
| | |
| | #11 (permalink) |
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,074
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Sorry ignore my last post. I forgot to notice you were in fact echo'ing the data.
__________________ Manage your portfolio using my new Domain Portfolio Management script. Securing Your Domain Name From Theft |
| | |
| | THREAD STARTER #12 (permalink) |
| NamePros Regular Join Date: Mar 2006
Posts: 887
![]() ![]() ![]() | I tried your suggestion again, however it still did not work. I am completely puzzled! Instead of reading each file, maybe I could just find a way to automatically add the entire folder. I feel that might be harder to code.
__________________ http://www.twitter.com/chrisrwilliams -- mention you're a NP'er, and i'll follow you back immediately |
| | |
| | #13 (permalink) |
| DNMedia.com Join Date: Jul 2007 Location: Maryland
Posts: 1,842
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | It's easier to just write a script to rebuild the file, instead of trying to correct the file. http://dnmedia.com/cwn_xml.xml |
| | |
| | THREAD STARTER #14 (permalink) |
| NamePros Regular Join Date: Mar 2006
Posts: 887
![]() ![]() ![]() | Michael, you just blew my mind. Thank you so much! And thank you qbert220 and Peter too, I really appreciate the efforts! Amazing!
__________________ http://www.twitter.com/chrisrwilliams -- mention you're a NP'er, and i'll follow you back immediately |
| | |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| quick question about PPC | Neeb | Domain Newbies | 0 | 06-19-2007 11:14 PM |
| Quick CMS Question | enocko | Website Development | 1 | 04-16-2007 10:39 PM |
| Quick domain reg question? | bertwrld | Domain Name Discussion | 2 | 02-13-2005 05:22 PM |
| Quick Question | Meilad | Programming | 4 | 06-04-2004 10:01 AM |