Help with ampersands in strings

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

printf
Forum Contributor
Posts: 173
Joined: Wed Jan 12, 2005 5:24 pm

Post by printf »

The ouput file doesn't show the error so what good is it?

You said your parsing this file....

xxx://l4eblog.blogspot.com/atom.xml

that get put into the document write JavaScript file!

So your saying...

But if there is a & in content string, it doesn't make into the document write JavaScript file! <= correct?


Now I tried it, using your script, and I got that error (no write), but if I convert it before giving it to the parser, I don't get the error and I can build the JavaScript file even with &(s) in the content string!

Your error is...

XML_ERR_NAME_REQUIRED, in this case, a litiral entity found, which shouldn't be there, they should be encoded....


Simple fix....

// change this....

Code: Select all

$xml_parser = xml_parser_create(); 
xml_set_element_handler($xml_parser, "startElement", "endElement"); 
xml_set_character_data_handler($xml_parser, "characterData"); 
$fp = fopen("http://l4eblog.blogspot.com/atom.xml","r") or die("Error reading RSS data."); 
while ($data = fread($fp, 4096)) 
        xml_parse($xml_parser, $data, feof($fp)) 
                or die(sprintf("XML error: %s at line %d", 
                        xml_error_string(xml_get_error_code($xml_parser)), 
                        xml_get_current_line_number($xml_parser))); 
fclose($fp); 
xml_parser_free($xml_parser);

// to this...

Code: Select all

// temp file....

$temp = './atom.xml';

// download and convert

$data = file_get_contents ( 'http://l4eblog.blogspot.com/atom.xml' );

$old = array ( '&', '&' );
$new = array ( '&', '&' );

file_put_contents ( $temp, str_replace ( $old, $new, $data ) );

unset ( $old, $new, $data );

$xml_parser = xml_parser_create(); 
xml_set_element_handler($xml_parser, "startElement", "endElement"); 
xml_set_character_data_handler($xml_parser, "characterData"); 
$fp = fopen("./atom.xml","rb") or die("Error reading RSS data."); 
while ($data = fread($fp, 4096)) 
        xml_parse($xml_parser, $data, feof($fp)) 
                or die(sprintf("XML error: %s at line %d", 
                        xml_error_string(xml_get_error_code($xml_parser)), 
                        xml_get_current_line_number($xml_parser))); 
fclose($fp);
unlink ( $temp );
xml_parser_free($xml_parser);

Edit...

The parser will convert &(s) back to & in strings auotmaticlly!


pif!
L4E_WakaMol-King
Forum Commoner
Posts: 26
Joined: Wed Jun 14, 2006 10:54 am

Post by L4E_WakaMol-King »

Hmm, I seem to be getting an error:
Fatal error: Call to undefined function: file_put_contents() in /hsphere/local/home/l4ewakam/l4eclan.com/headfoot/forumblog.php on line 147
Line 147:
file_put_contents ( $temp, str_replace ( $old, $new, $data ) );
Found the problem. The company that hosts my server only has up to PHP 4.2.1 :(.

Is there any way to do it without that function?
Last edited by L4E_WakaMol-King on Thu Jun 15, 2006 10:41 pm, edited 3 times in total.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

fyi, file_put_contents() is php5+
L4E_WakaMol-King
Forum Commoner
Posts: 26
Joined: Wed Jun 14, 2006 10:54 am

Post by L4E_WakaMol-King »

(Sorry, those last 2 lines were an edit... didn't know someone would post so fast ;). Thanks though!)
printf
Forum Contributor
Posts: 173
Joined: Wed Jan 12, 2005 5:24 pm

Post by printf »

Sorry about that!

// change this

Code: Select all

file_put_contents ( $temp, str_replace ( $old, $new, $data ) );
// to this...

Code: Select all

$io = fopen ( $temp, 'w' );
fputs ( $io, str_replace ( $old, $new, $data ) );
fclose ( $io );

pif!
L4E_WakaMol-King
Forum Commoner
Posts: 26
Joined: Wed Jun 14, 2006 10:54 am

Post by L4E_WakaMol-King »

Hmm...
Warning: fopen(./atom.xml): failed to open stream: Permission denied in /hsphere/local/home/l4ewakam/l4eclan.com/headfoot/forumblog.php on line 148

Warning: fputs(): supplied argument is not a valid stream resource in /hsphere/local/home/l4ewakam/l4eclan.com/headfoot/forumblog.php on line 149

Warning: fclose(): supplied argument is not a valid stream resource in /hsphere/local/home/l4ewakam/l4eclan.com/headfoot/forumblog.php on line 150

Warning: fopen(./atom.xml): failed to open stream: No such file or directory in /hsphere/local/home/l4ewakam/l4eclan.com/headfoot/forumblog.php on line 157
Error reading RSS data.
Lines 148 - 150
$io = fopen ( $temp, 'w' );
fputs ( $io, str_replace ( $old, $new, $data ) );
fclose ( $io );
Lines 157
$fp = fopen("./atom.xml","rb") or die("Error reading RSS data.");
This is just a wbe server, so if this code is creating a file on the server, than I might not have permission to do that.

I tried replacing 157 with this:
$fp = fopen("http://l4eblog.blogspot.com/atom.xml","rb") or die("Error reading RSS data.");

But no luck :?.
printf
Forum Contributor
Posts: 173
Joined: Wed Jan 12, 2005 5:24 pm

Post by printf »

If you can not do it there (file write), then do it in your while(), I didn't want to do it there because each line would need to run the str_replace(), if you can not write to a IO, then do it that way (in the while(loop) using fgets()).....

Again change your orignal code.... (remove eveything I told you to do before)

then, change this.... (your original code)

Code: Select all

$xml_parser = xml_parser_create(); 
xml_set_element_handler($xml_parser, "startElement", "endElement"); 
xml_set_character_data_handler($xml_parser, "characterData"); 
$fp = fopen("http://l4eblog.blogspot.com/atom.xml","rb") or die("Error reading RSS data."); 
while ($data = fread($fp, 4096)) 
        xml_parse($xml_parser, $data, feof($fp)) 
                or die(sprintf("XML error: %s at line %d", 
                        xml_error_string(xml_get_error_code($xml_parser)), 
                        xml_get_current_line_number($xml_parser))); 
fclose($fp); 
xml_parser_free($xml_parser);
to this.... (I changed fread(), to fgets() so it read a single line to EOL, so you don't cut off a special character, and I add the str_replace to the while();)!!!!!

Code: Select all

$xml_parser = xml_parser_create(); 
xml_set_element_handler($xml_parser, "startElement", "endElement"); 
xml_set_character_data_handler($xml_parser, "characterData"); 
$fp = fopen("http://l4eblog.blogspot.com/atom.xml","rb") or die("Error reading RSS data."); 
while ( $data = fgets ( $fp, 4096 ) ) 
        xml_parse ( $xml_parser, ( str_replace ( array ( '&', '&' ), array ( '&', '&' ), $data ) ), feof ( $fp ) ) 
                or die(sprintf("XML error: %s at line %d", 
                        xml_error_string(xml_get_error_code($xml_parser)), 
                        xml_get_current_line_number($xml_parser))); 
fclose($fp); 
xml_parser_free($xml_parser);
pif!
L4E_WakaMol-King
Forum Commoner
Posts: 26
Joined: Wed Jun 14, 2006 10:54 am

Post by L4E_WakaMol-King »

Parse error: parse error, unexpected T_STRING in /hsphere/local/home/l4ewakam/l4eclan.com/headfoot/forumblog.php on line 142
Line 142:
xml_parse ( $xml_parser, ( str_replace ( array ( '&', '&' ), array ( '&', '&' ), $data ), feof ( $fp ) )
I'm sorry this is being so annoying... I had no idea ampersands could be so troublesome. :(
printf
Forum Contributor
Posts: 173
Joined: Wed Jan 12, 2005 5:24 pm

Post by printf »

Sorry you copied the code before I changed it....


here....

Code: Select all

xml_parse ( $xml_parser, ( str_replace ( array ( '&', '&' ), array ( '&', '&' ), $data ), feof ( $fp ) )
//------------------------------------problem - here-------------------------------------------^
missing a closing *)*


recopy the code I posted in my last post, I fixed it there...

pif!
L4E_WakaMol-King
Forum Commoner
Posts: 26
Joined: Wed Jun 14, 2006 10:54 am

Post by L4E_WakaMol-King »

Printf, I really do appreciate your help with this. I'm sorry it's being such an annoying code :?.

The script parses again with no errors, but it's still not outputting any of the content string if the content has an '&' anywhere in it. :(
Important Links
The PHP script, which outputs as the source code for a javascript: http://l4eclan.com/headfoot/forumblog.php
The javascript in use, for putting a blog on a forum: http://l4ewakamolking.proboards39.com/index.cgi?
The Blog: http://l4eblog.blogspot.com/
The XML output of the blog which the php script reads: http://l4eblog.blogspot.com/atom.xml
My current code:

Code: Select all

<?php

$insideitem = false;
$tag = "";
$title = "";
$author = "";
$date = "";
$month = "";
$day = "";
$year = "";
$content = "";
$loopnum = 0;

function startElement($parser, $name, $attrs) {
	global $insideitem, $tag, $title, $author, $date, $content;
	if ($insideitem) {
		$tag = $name;
	} elseif ($name == "ENTRY") {
		$insideitem = true;
	}
}

function endElement($parser, $name) {
	global $insideitem, $tag, $title, $author, $date, $month, $day, $year, $content, $loopnum;
	if ($name == "ENTRY") {

 	$title = str_replace("'", "\'", $title);
 	$content = str_replace("\n", "", $content);
	$content = str_replace("'", "\'", $content);
	$content = str_replace("[url]", "<a href=\'", $content);
	$content = str_replace("[/url/]", "\'>", $content);
	$content = str_replace("[/url]", "</a>", $content);

		echo 'document.write(\'<tr>\');
';

		printf('document.write(\'<td class="windowbg" valign="top"><img id="p%s" src="http://l4eclan.com/images/blogavatars/%s.gif" style="display: none" /></td>\');', $loopnum, trim($author));
		echo '
document.write(\'<td class="windowbg2">\');
';
		printf('document.write(\'<b><a onclick="display(%s)" style="color: #0099FF; cursor: pointer">%s</a></b>\');', $loopnum, trim($title));
		echo '
';
		printf('document.write(\'<p id="t%s" style="display: none"><br /><br />%s</p></td>\');', $loopnum, trim($content));
		echo '
';
		printf('document.write(\'<td colspan="2" class="windowbg" valign="top"><center><b>%s<b></center></td>\');', trim($author));
		echo '
';
		printf('document.write(\'<td class="windowbg2" valign="top"><center>%s %s, %s</center></td>\');', $month, $day, $year);
		echo '
document.write(\'</tr>\');
';

		$title = "";
		$author = "";
		$date = "";
		$content = "";
		$loopnum = $loopnum + 1;
		$insideitem = false;
	}
}

function characterData($parser, $data) {
	global $insideitem, $tag, $title, $author, $date, $month, $day, $year, $content;
	if ($insideitem) {
	switch ($tag) {
		case "TITLE":
		$title .= $data;
		break;
		case "NAME":
		$author .= $data;
		break;
		case "CREATED":
		$date .= $data;
		break;
		case "DIV":
		$content .= $data;
		break;
		case "BR":
		$content .= "<br />" . $data;
 		break; }

	switch (substr($date,5,2)) {
		case "01":
		$month = "January";
		break;
		case "02":
		$month = "February";
		break;
		case "03":
		$month = "March";
		break;
		case "04":
		$month = "April";
		break;
		case "05":
		$month = "May";
		break;
		case "06":
		$month = "June";
		break;
		case "07":
		$month = "July";
		break;
		case "08":
		$month = "August";
		break;
		case "09":
		$month = "Semptember";
		break;
		case "10":
		$month = "October";
		break;
		case "11":
		$month = "November";
		break;
		case "12":
		$month = "December";
		break; }

	$day = (substr($date,8,2));
	$year = (substr($date,0,4));

	}
}

echo '
document.write(\'<table id="forCat" style="display: none;">\');
document.write(\'<tr>\');
document.write(\'<td class="windowbg" colspan="4"><b><font size="2">Recent Posts on the L4E Blog</font></b></td>\');
document.write(\'<td class="windowbg" align="center">[<a href="http://www.blogger.com/post-create.g?blogID=19669778" target="_blank">New Post</a>] [<a href="http://l4ewakamolking.proboards39.com/index.cgi?action=display&board=L4Earchives&thread=1150270549&page=1"><font style="color: #0099FF">?</font></a>]</td>\');
document.write(\'</tr>\');
';

$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen("http://l4eblog.blogspot.com/atom.xml","rb") or die("Error reading RSS data.");
while ( $data = fgets ( $fp, 4096 ) )
        xml_parse ( $xml_parser, ( str_replace ( array ( '&', '&' ), array ( '&', '&' ), $data ) ), feof ( $fp ) )
                or die(sprintf("XML error: %s at line %d",
                        xml_error_string(xml_get_error_code($xml_parser)),
                        xml_get_current_line_number($xml_parser)));
fclose($fp);
xml_parser_free($xml_parser);

echo '
document.write(\'</table>\'); document.write(\'<script type="text/javascript">function display(num) { if (document.getElementById("p" + num).style.display == "none") { document.getElementById("p" + num).style.display="inline"; document.getElementById("t" + num).style.display="inline"; } else { document.getElementById("p" + num).style.display="none"; document.getElementById("t" + num).style.display="none"; } }</script>\');
';

?>
printf
Forum Contributor
Posts: 173
Joined: Wed Jan 12, 2005 5:24 pm

Post by printf »

Make me a XML file with &(s) in any of the content string in the XML file and post a link to it, I have tested this fully, including displaying the list with the icons and collapseble messages and they all display fine, even ones with &!

Let me make a demo, that you can try, with your XML example and your code, check back in a little bit! But post a XML file with what I asked for, so I know I am placing the &(s) in the right place for my test!


pif!
L4E_WakaMol-King
Forum Commoner
Posts: 26
Joined: Wed Jun 14, 2006 10:54 am

Post by L4E_WakaMol-King »

I'm not sure I know what you mean. Would this work?

Code: Select all

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?>

<feed xmlns="http://purl.org/atom/ns#" version="0.3" xml:lang="en-US">
<link href="https://www.blogger.com/atom/19669778" rel="service.post" title="L4E Blog" type="application/atom+xml"/>
<link href="https://www.blogger.com/atom/19669778" rel="service.feed" title="L4E Blog" type="application/atom+xml"/>
<title mode="escaped" type="text/html">L4E Blog</title>
<tagline mode="escaped" type="text/html">This is the blog for the Luzers 4 Eva Dinky Bomb Clan. It is meant to be viewed at <a href=www.l4eclan.com>www.l4eclan.com</a></tagline>
<link href="http://l4eblog.blogspot.com" rel="alternate" title="L4E Blog" type="text/html"/>
<id>tag:blogger.com,1999:blog-19669778</id>
<modified>2006-06-16T22:18:51Z</modified>

<generator url="http://www.blogger.com/" version="6.72">Blogger</generator>
<info mode="xml" type="text/html">
<div xmlns="http://www.w3.org/1999/xhtml">This is an Atom formatted XML site feed. It is intended to be viewed in a Newsreader or syndicated to another site. Please visit the <a href="http://help.blogger.com/bin/answer.py?answer=697">Blogger Help</a> for more info.</div>
</info>
<convertLineBreaks xmlns="http://www.blogger.com/atom/ns#">true</convertLineBreaks>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/19669778/115049623349347985" rel="service.edit" title="Balls! 2" type="application/atom+xml"/>
<author>
<name>Bean</name>
</author>

<issued>2006-06-16T22:15:00+00:00</issued>
<modified>2006-06-16T22:18:51Z</modified>
<created>2006-06-16T22:17:13Z</created>
<link href="http://l4eblog.blogspot.com/2006/06/balls-2.html" rel="alternate" title="Balls! 2" type="text/html"/>
<id>tag:blogger.com,1999:blog-19669778.post-115049623349347985</id>
<title mode="escaped" type="text/html">Balls! 2</title>
<content type="application/xhtml+xml" xml:base="http://l4eblog.blogspot.com" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">Hmmm... It seems some of my message was cut off in my last Balls post...so let me say it again...<br/>
<br/>Me and Tay make out heavily and massively. Respek it.<br/>
<br/>King... I think the reason why it didnt post the rest of my first Balls message.. as i just checked it.. is because the rest was in different font? Like one sentece was in bold, another in italics, another in a different color? Could that be why?</div>

</content>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/19669778/115048934038632691" rel="service.edit" title="Balls!" type="application/atom+xml"/>
<author>
<name>Bean</name>
</author>
<issued>2006-06-16T19:45:00+00:00</issued>
<modified>2006-06-16T20:22:20Z</modified>
<created>2006-06-16T20:22:20Z</created>
<link href="http://l4eblog.blogspot.com/2006/06/balls.html" rel="alternate" title="Balls!" type="text/html"/>

<id>tag:blogger.com,1999:blog-19669778.post-115048934038632691</id>
<title mode="escaped" type="text/html">Balls!</title>
<content type="application/xhtml+xml" xml:base="http://l4eblog.blogspot.com" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">
<a href="http://photos1.blogger.com/blogger/5098/3126/1600/love.0.jpg"/>
<br/>
<br/>Balls!<br/>
<br/>I love Tay.<br/>
<strong>I love Tay.</strong>
<br/>
<em>I love Tay.</em> <a href="http://photos1.blogger.com/blogger/5098/3126/1600/love.jpg"/>

<br/>
<span style="color:#3366ff;">I Love Tay.</span>
<br/>
<strong>
<em>
<span style="color:#3366ff;">I love Tay.</span>
</em>
</strong>
<br/>
<br/>
<span style="color:#ff0000;">We make out massively and heavily.</span>
<br/>
<span style="color:#ff0000;">No joke.<br/>

<br/>
<br/>
</span>
<span style="color:#ff0000;"/>
<div align="justify"/>
</div>
</content>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/19669778/115041026749430818" rel="service.edit" title="Link Test 2" type="application/atom+xml"/>
<author>
<name>King</name>
</author>
<issued>2006-06-15T22:24:00+00:00</issued>

<modified>2006-06-15T22:33:35Z</modified>
<created>2006-06-15T22:24:27Z</created>
<link href="http://l4eblog.blogspot.com/2006/06/link-test-2.html" rel="alternate" title="Link Test 2" type="text/html"/>
<id>tag:blogger.com,1999:blog-19669778.post-115041026749430818</id>
<title mode="escaped" type="text/html">Link Test 2</title>
<content type="application/xhtml+xml" xml:base="http://l4eblog.blogspot.com" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">Let's try again... <a href="www.google.com">Test</a>
</div>
</content>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>

</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/19669778/115040610391809215" rel="service.edit" title="Link Test" type="application/atom+xml"/>
<author>
<name>King</name>
</author>
<issued>2006-06-15T21:12:00+00:00</issued>
<modified>2006-06-15T21:15:03Z</modified>
<created>2006-06-15T21:15:03Z</created>
<link href="http://l4eblog.blogspot.com/2006/06/link-test.html" rel="alternate" title="Link Test" type="text/html"/>
<id>tag:blogger.com,1999:blog-19669778.post-115040610391809215</id>
<title mode="escaped" type="text/html">Link Test</title>

<content mode="escaped" type="text/html" xml:base="http://l4eblog.blogspot.com" xml:space="preserve">http://www.weplayhere.com/highscores.php?action=vm_high_scores&page=2</content>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/19669778/115040358691879342" rel="service.edit" title="Check your Credit Report for Free!" type="application/atom+xml"/>
<author>
<name>Duckie</name>
</author>
<issued>2006-06-15T20:32:00+00:00</issued>
<modified>2006-06-15T20:33:06Z</modified>
<created>2006-06-15T20:33:06Z</created>

<link href="http://l4eblog.blogspot.com/2006/06/check-your-credit-report-for-free.html" rel="alternate" title="Check your Credit Report for Free!" type="text/html"/>
<id>tag:blogger.com,1999:blog-19669778.post-115040358691879342</id>
<title mode="escaped" type="text/html">Check your Credit Report for Free!</title>
<content type="application/xhtml+xml" xml:base="http://l4eblog.blogspot.com" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">Jade is hawt furshizzle.</div>
</content>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/19669778/115034690836638656" rel="service.edit" title="ashley's cute" type="application/atom+xml"/>
<author>
<name>Jade</name>

</author>
<issued>2006-06-15T04:47:00+00:00</issued>
<modified>2006-06-15T16:52:44Z</modified>
<created>2006-06-15T04:48:28Z</created>
<link href="http://l4eblog.blogspot.com/2006/06/ashleys-cute.html" rel="alternate" title="ashley's cute" type="text/html"/>
<id>tag:blogger.com,1999:blog-19669778.post-115034690836638656</id>
<title mode="escaped" type="text/html">ashley's cute</title>
<content type="application/xhtml+xml" xml:base="http://l4eblog.blogspot.com" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">ashleys cute.<br/>the end.</div>
</content>

<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/19669778/115034169441283222" rel="service.edit" title="ahh i am kinda confused" type="application/atom+xml"/>
<author>
<name>Tay</name>
</author>
<issued>2006-06-15T03:18:00+00:00</issued>
<modified>2006-06-15T16:52:19Z</modified>
<created>2006-06-15T03:21:34Z</created>
<link href="http://l4eblog.blogspot.com/2006/06/ahh-i-am-kinda-confused_15.html" rel="alternate" title="ahh i am kinda confused" type="text/html"/>
<id>tag:blogger.com,1999:blog-19669778.post-115034169441283222</id>

<title mode="escaped" type="text/html">ahh i am kinda confused</title>
<content type="application/xhtml+xml" xml:base="http://l4eblog.blogspot.com" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">Testing... test test<br/>I Love Bean!<br/>King this is hawt i like it alot =]</div>
</content>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/19669778/115033299936061445" rel="service.edit" title="La la." type="application/atom+xml"/>
<author>
<name>Katie</name>
</author>

<issued>2006-06-15T00:52:00+00:00</issued>
<modified>2006-06-15T00:56:39Z</modified>
<created>2006-06-15T00:56:39Z</created>
<link href="http://l4eblog.blogspot.com/2006/06/la-la.html" rel="alternate" title="La la." type="text/html"/>
<id>tag:blogger.com,1999:blog-19669778.post-115033299936061445</id>
<title mode="escaped" type="text/html">La la.</title>
<content type="application/xhtml+xml" xml:base="http://l4eblog.blogspot.com" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">This is pretty sweet!</div>
</content>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>

</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/19669778/115031755026514732" rel="service.edit" title="The best ever." type="application/atom+xml"/>
<author>
<name>Monkey</name>
</author>
<issued>2006-06-14T20:37:00+00:00</issued>
<modified>2006-06-14T20:58:42Z</modified>
<created>2006-06-14T20:39:10Z</created>
<link href="http://l4eblog.blogspot.com/2006/06/best-ever.html" rel="alternate" title="The best ever." type="text/html"/>
<id>tag:blogger.com,1999:blog-19669778.post-115031755026514732</id>
<title mode="escaped" type="text/html">The best ever.</title>

<content type="application/xhtml+xml" xml:base="http://l4eblog.blogspot.com" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">American V:  A Hundred Highways<br/>4th of July, 2006<br/>
<br/>In the months leading up to his passing on September 12, 2003, JOHNNY CASH had been recording new material with producer Rick Rubin. On July 4, 2006, American V: A Hundred Highways, the all-new Johnny Cash album taken from those sessions, will be released on the American Recordings label through Lost Highway. It will include the last song Cash ever wrote, "Like the 309".<br/>
<br/>  Help Me<br/>  Gods Gonna Cut You Down<br/>  Like the 309 (the last song written by Johnny Cash)<br/>  If You Could Read My Mind<br/>  Further On Up the Road<br/>  The Evening Train<br/>  I Came to Believe<br/>  Love's Been Good To Me<br/>  A Legend In My Time<br/>  Rose of My Heart<br/>  Four Strong Winds<br/>  Im Free From the Chain Gang Now</div>

</content>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/19669778/115031844107064853" rel="service.edit" title="News of the day! (test? hopefully not a test...should work)" type="application/atom+xml"/>
<author>
<name>Bonyicecream</name>
</author>
<issued>2006-06-14T20:36:00+00:00</issued>
<modified>2006-06-14T20:54:01Z</modified>
<created>2006-06-14T20:54:01Z</created>
<link href="http://l4eblog.blogspot.com/2006/06/news-of-day-test-hopefully-not.html" rel="alternate" title="News of the day! (test? hopefully not a test...should work)" type="text/html"/>

<id>tag:blogger.com,1999:blog-19669778.post-115031844107064853</id>
<title mode="escaped" type="text/html">News of the day! (test? hopefully not a test...should work)</title>
<content mode="escaped" type="text/html" xml:base="http://l4eblog.blogspot.com" xml:space="preserve"><a href="http://www.wvnstv.com/story.cfm?func=viewstory&storyid=11584">When breaking into a business to get even for being fired, remember to sober up to the point where you can distinguish its building from a Dollar General</a><br /><a href="http://www.kesq.com/Global/story.asp?S=5028463&amp;nav=9qrx">Man digs for gold in his front yard, proudly announces that he has struck dirt 60 feet down</a><br /><a href="http://www.mirror.co.uk/news/tm_objectid=17226632&method=full&amp;siteid=94762&headline=jail-threat-for-speed-sign-ruse--name_page.html">You can't beat a speeding ticket by tearing down a speed limit sign and pasting it over the lower-limit sign you are accused of ignoring, particularly if prosecutors haul in facial scanning experts</a><br /><a href="http://www.woai.com/news/local/story.aspx?content_id=e1368523-1d22-47d1-bfa1-8e7d1a009dda&amp;rss=68">"Dukes of Hazzard" style car chase races through neighborhood, ditches, medians, and a military runway in the path of a C-130 as it's taking off</a><br /><a href="http://www.allheadlinenews.com/articles/7003883980">Belgian couple with 14 children, all with named ending in "Y", put ad in newspaper asking for ideas because they can't come up with a name for their 15th</a><br /><br />Ok, that's enough weird news for now!(credit goes to fark.com)(just so i dont get sued)</content>

<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
</feed>
The fourth post (titled "Link Test") has the following text:
Let's try this: http://www.weplayhere.com/highscores.ph ... res&page=2 and see if it works.
L4E_WakaMol-King
Forum Commoner
Posts: 26
Joined: Wed Jun 14, 2006 10:54 am

Post by L4E_WakaMol-King »

Is that what you needed? Here's a different copy, where the last 3 posts all have &'s in them in different ways.

Code: Select all

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?>

<feed xmlns="http://purl.org/atom/ns#" version="0.3" xml:lang="en-US">
<link href="https://www.blogger.com/atom/19669778" rel="service.post" title="L4E Blog" type="application/atom+xml"/>
<link href="https://www.blogger.com/atom/19669778" rel="service.feed" title="L4E Blog" type="application/atom+xml"/>
<title mode="escaped" type="text/html">L4E Blog</title>
<tagline mode="escaped" type="text/html">This is the blog for the Luzers 4 Eva Dinky Bomb Clan. It is meant to be viewed at <a href=www.l4eclan.com>www.l4eclan.com</a></tagline>
<link href="http://l4eblog.blogspot.com" rel="alternate" title="L4E Blog" type="text/html"/>
<id>tag:blogger.com,1999:blog-19669778</id>
<modified>2006-06-17T03:33:18Z</modified>

<generator url="http://www.blogger.com/" version="6.72">Blogger</generator>
<info mode="xml" type="text/html">
<div xmlns="http://www.w3.org/1999/xhtml">This is an Atom formatted XML site feed. It is intended to be viewed in a Newsreader or syndicated to another site. Please visit the <a href="http://help.blogger.com/bin/answer.py?answer=697">Blogger Help</a> for more info.</div>
</info>
<convertLineBreaks xmlns="http://www.blogger.com/atom/ns#">true</convertLineBreaks>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/19669778/115051519847566958" rel="service.edit" title="Bean is the Non-Balls L4E Associate." type="application/atom+xml"/>
<author>
<name>Duckie</name>
</author>

<issued>2006-06-17T03:26:00+00:00</issued>
<modified>2006-06-17T03:33:18Z</modified>
<created>2006-06-17T03:33:18Z</created>
<link href="http://l4eblog.blogspot.com/2006/06/bean-is-non-balls-l4e-associate.html" rel="alternate" title="Bean is the Non-Balls L4E Associate." type="text/html"/>
<id>tag:blogger.com,1999:blog-19669778.post-115051519847566958</id>
<title mode="escaped" type="text/html">Bean is the Non-Balls L4E Associate.</title>
<content type="application/xhtml+xml" xml:base="http://l4eblog.blogspot.com" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">Bean is a chump. Respek it. <br/>
<br/>
<br/>Beskides...<br/>

<br/>I makeout with Justin like 882 times what you and Tay do. You don't even know. And then I blew King a kiss, and he madeout with Queenie 543 times. And then King blew a kiss to Jade, and me and her madeout 881 times. And then Jade blew Ryan a kiss, and him and Monkey madeout 455 times.<br/>
<br/>In concrusion...<br/>
<br/>Tay and the Bean hardly makeout at all.</div>
</content>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/19669778/115049623349347985" rel="service.edit" title="Balls! 2" type="application/atom+xml"/>
<author>
<name>Bean</name>
</author>
<issued>2006-06-16T22:15:00+00:00</issued>

<modified>2006-06-16T22:18:51Z</modified>
<created>2006-06-16T22:17:13Z</created>
<link href="http://l4eblog.blogspot.com/2006/06/balls-2.html" rel="alternate" title="Balls! 2" type="text/html"/>
<id>tag:blogger.com,1999:blog-19669778.post-115049623349347985</id>
<title mode="escaped" type="text/html">Balls! 2</title>
<content type="application/xhtml+xml" xml:base="http://l4eblog.blogspot.com" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">Hmmm... It seems some of my message was cut off in my last Balls post...so let me say it again...<br/>
<br/>Me and Tay make out heavily and massively. Respek it.<br/>
<br/>King... I think the reason why it didnt post the rest of my first Balls message.. as i just checked it.. is because the rest was in different font? Like one sentece was in bold, another in italics, another in a different color? Could that be why?</div>
</content>

<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/19669778/115048934038632691" rel="service.edit" title="Balls!" type="application/atom+xml"/>
<author>
<name>Bean</name>
</author>
<issued>2006-06-16T19:45:00+00:00</issued>
<modified>2006-06-16T20:22:20Z</modified>
<created>2006-06-16T20:22:20Z</created>
<link href="http://l4eblog.blogspot.com/2006/06/balls.html" rel="alternate" title="Balls!" type="text/html"/>
<id>tag:blogger.com,1999:blog-19669778.post-115048934038632691</id>

<title mode="escaped" type="text/html">Balls!</title>
<content type="application/xhtml+xml" xml:base="http://l4eblog.blogspot.com" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">
<a href="http://photos1.blogger.com/blogger/5098/3126/1600/love.0.jpg"/>
<br/>
<br/>Balls!<br/>
<br/>I love Tay.<br/>
<strong>I love Tay.</strong>
<br/>
<em>I love Tay.</em> <a href="http://photos1.blogger.com/blogger/5098/3126/1600/love.jpg"/>
<br/>

<span style="color:#3366ff;">I Love Tay.</span>
<br/>
<strong>
<em>
<span style="color:#3366ff;">I love Tay.</span>
</em>
</strong>
<br/>
<br/>
<span style="color:#ff0000;">We make out massively and heavily.</span>
<br/>
<span style="color:#ff0000;">No joke.<br/>
<br/>

<br/>
</span>
<span style="color:#ff0000;"/>
<div align="justify"/>
</div>
</content>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/19669778/115041026749430818" rel="service.edit" title="Link Test 2" type="application/atom+xml"/>
<author>
<name>King</name>
</author>
<issued>2006-06-15T22:24:00+00:00</issued>

<modified>2006-06-15T22:33:35Z</modified>
<created>2006-06-15T22:24:27Z</created>
<link href="http://l4eblog.blogspot.com/2006/06/link-test-2.html" rel="alternate" title="Link Test 2" type="text/html"/>
<id>tag:blogger.com,1999:blog-19669778.post-115041026749430818</id>
<title mode="escaped" type="text/html">Link Test 2</title>
<content type="application/xhtml+xml" xml:base="http://l4eblog.blogspot.com" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">Let's try again... <a href="www.google.com">Test</a>
</div>
</content>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>

</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/19669778/115040610391809215" rel="service.edit" title="Link Test" type="application/atom+xml"/>
<author>
<name>King</name>
</author>
<issued>2006-06-15T21:12:00+00:00</issued>
<modified>2006-06-16T22:51:42Z</modified>
<created>2006-06-15T21:15:03Z</created>
<link href="http://l4eblog.blogspot.com/2006/06/link-test.html" rel="alternate" title="Link Test" type="text/html"/>
<id>tag:blogger.com,1999:blog-19669778.post-115040610391809215</id>
<title mode="escaped" type="text/html">Link Test</title>

<content mode="escaped" type="text/html" xml:base="http://l4eblog.blogspot.com" xml:space="preserve">Let's try this: http://www.weplayhere.com/highscores.php?action=vm_high_scores&page=2 and see if it works.</content>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/19669778/115040358691879342" rel="service.edit" title="Check your Credit Report for Free!" type="application/atom+xml"/>
<author>
<name>Duckie</name>
</author>
<issued>2006-06-15T20:32:00+00:00</issued>
<modified>2006-06-15T20:33:06Z</modified>
<created>2006-06-15T20:33:06Z</created>

<link href="http://l4eblog.blogspot.com/2006/06/check-your-credit-report-for-free.html" rel="alternate" title="Check your Credit Report for Free!" type="text/html"/>
<id>tag:blogger.com,1999:blog-19669778.post-115040358691879342</id>
<title mode="escaped" type="text/html">Check your Credit Report for Free!</title>
<content type="application/xhtml+xml" xml:base="http://l4eblog.blogspot.com" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">Jade is hawt furshizzle.</div>
</content>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/19669778/115034690836638656" rel="service.edit" title="ashley's cute" type="application/atom+xml"/>
<author>
<name>Jade</name>

</author>
<issued>2006-06-15T04:47:00+00:00</issued>
<modified>2006-06-15T16:52:44Z</modified>
<created>2006-06-15T04:48:28Z</created>
<link href="http://l4eblog.blogspot.com/2006/06/ashleys-cute.html" rel="alternate" title="ashley's cute" type="text/html"/>
<id>tag:blogger.com,1999:blog-19669778.post-115034690836638656</id>
<title mode="escaped" type="text/html">ashley's cute</title>
<content type="application/xhtml+xml" xml:base="http://l4eblog.blogspot.com" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">ashleys cute.<br/>the end.</div>
</content>

<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/19669778/115034169441283222" rel="service.edit" title="ahh i am kinda confused" type="application/atom+xml"/>
<author>
<name>Tay</name>
</author>
<issued>2006-06-15T03:18:00+00:00</issued>
<modified>2006-06-15T16:52:19Z</modified>
<created>2006-06-15T03:21:34Z</created>
<link href="http://l4eblog.blogspot.com/2006/06/ahh-i-am-kinda-confused_15.html" rel="alternate" title="ahh i am kinda confused" type="text/html"/>
<id>tag:blogger.com,1999:blog-19669778.post-115034169441283222</id>

<title mode="escaped" type="text/html">ahh i am kinda confused</title>
<content type="application/xhtml+xml" xml:base="http://l4eblog.blogspot.com" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">Testing... test test<br/>I Love Bean!<br/>King this is hawt i like it alot =]</div>
</content>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/19669778/115033299936061445" rel="service.edit" title="La la." type="application/atom+xml"/>
<author>
<name>Katie</name>
</author>

<issued>2006-06-15T00:52:00+00:00</issued>
<modified>2006-06-15T00:56:39Z</modified>
<created>2006-06-15T00:56:39Z</created>
<link href="http://l4eblog.blogspot.com/2006/06/la-la.html" rel="alternate" title="La la." type="text/html"/>
<id>tag:blogger.com,1999:blog-19669778.post-115033299936061445</id>
<title mode="escaped" type="text/html">La la.</title>
<content type="application/xhtml+xml" xml:base="http://l4eblog.blogspot.com" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">This is pretty sweet!</div>
</content>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>

</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link href="https://www.blogger.com/atom/19669778/115031755026514732" rel="service.edit" title="The best ever." type="application/atom+xml"/>
<author>
<name>Monkey</name>
</author>
<issued>2006-06-14T20:37:00+00:00</issued>
<modified>2006-06-14T20:58:42Z</modified>
<created>2006-06-14T20:39:10Z</created>
<link href="http://l4eblog.blogspot.com/2006/06/best-ever.html" rel="alternate" title="The best ever." type="text/html"/>
<id>tag:blogger.com,1999:blog-19669778.post-115031755026514732</id>
<title mode="escaped" type="text/html">The best ever.</title>

<content type="application/xhtml+xml" xml:base="http://l4eblog.blogspot.com" xml:space="preserve">
<div xmlns="http://www.w3.org/1999/xhtml">American V:  A Hundred Highways<br/>4th of July, 2006<br/>
<br/>In the months leading up to his passing on September 12, 2003, JOHNNY CASH had been recording new material with producer Rick Rubin. On July 4, 2006, American V: A Hundred Highways, the all-new Johnny Cash album taken from those sessions, will be released on the American Recordings label through Lost Highway. It will include the last song Cash ever wrote, "Like the 309".<br/>
<br/>  Help Me<br/>  Gods Gonna Cut You Down<br/>  Like the 309 (the last song written by Johnny Cash)<br/>  If You Could Read My Mind<br/>  Further On Up the Road<br/>  The Evening Train<br/>  I Came to Believe<br/>  Love's Been Good To Me<br/>  A Legend In My Time<br/>  Rose of My Heart<br/>  Four Strong Winds<br/>  Im Free From the Chain Gang Now</div>

</content>
<draft xmlns="http://purl.org/atom-blog/ns#">false</draft>
</entry>
</feed>
The three post recent posts read:
Link Test #2
& Test &
Link Test #3
I heart links & blogs!
printf
Forum Contributor
Posts: 173
Joined: Wed Jan 12, 2005 5:24 pm

Post by printf »

You don't need to post all that, all I want to know is where &(s) are when your code doesn't add them to the JavaScript creation file...

Are they in the????

<title mode="escaped" type="text/html">
Are they in here => &&&&
</title>

<content type="application/xhtml+xml" xml:base="http://l4eblog.blogspot.com" xml:space="preserve">
Are they in here => &&&&
</content>

<author>
Are they in here => &&&&
</author>


I'll post you my example a few minutes, so you can see it works for me no matter where I put any (encoded entity, &, &)!

pif!
L4E_WakaMol-King
Forum Commoner
Posts: 26
Joined: Wed Jun 14, 2006 10:54 am

Post by L4E_WakaMol-King »

printf wrote:<content type="application/xhtml+xml" xml:base="http://l4eblog.blogspot.com" xml:space="preserve">
Are they in here => &&&&
</content>
Yes, if the &'s appear in the content tags in the XML document, the whole thing never makes it into the javascript output.

I assume the problem happens here, but I don't know:

Code: Select all

printf('document.write(\'<p id="t%s" style="display: none"><br /><br />%s</p></td>\');', $loopnum, trim($content));
Post Reply