By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,278 Members | 1,357 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,278 IT Pros & Developers. It's quick & easy.

Echoing xml vars

P: n/a
I have a site that I need to generate a sitemap for. It is way to big
for a desktop program to crawl or any of the online sites. It
technically only has 4 pages but it runs from a DB with a couple
thousand pages. My plan is to generate a giant sitemap with a php file
querying the database and copy and pasting into a real xml file but I
hit a problem. I have tried the following code but no matter what I do
it always seems to takeout the < and >

<?php
$db_host = "localhost";
$db_user = "name";
$db_pwd = "pass";
$db_name = "db name";
$con = mysql_connect($db_host, $db_user, $db_pwd);
mysql_select_db($db_name);
$result = mysql_query("SELECT * FROM db");
while($data = mysql_fetch_row($result)){
echo("
<url><br />
<loc>http://www.mysite.com/-$data[0].html</loc><br />
<priority>0.90</priority><br />
<changefreq>daily</changefreq><br />
<lastmod>2008-09-02</lastmod><br />
</url><br />");
}
?>

And when run it shows:

http://www.mysite.com/-data.html
0.90
daily
2008-09-02
It echos everything but the xml tags (Which is what I need). Is there
a correct way of doing this or tricking it somehow?

Thanks in Advance,
Bryan
Sep 5 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
..oO(BryanA)
>I have a site that I need to generate a sitemap for. It is way to big
for a desktop program to crawl or any of the online sites. It
technically only has 4 pages but it runs from a DB with a couple
thousand pages. My plan is to generate a giant sitemap with a php file
querying the database and copy and pasting into a real xml file but I
hit a problem. I have tried the following code but no matter what I do
it always seems to takeout the < and >

<?php
$db_host = "localhost";
$db_user = "name";
$db_pwd = "pass";
$db_name = "db name";
$con = mysql_connect($db_host, $db_user, $db_pwd);
mysql_select_db($db_name);
$result = mysql_query("SELECT * FROM db");
while($data = mysql_fetch_row($result)){
echo("
<url><br />
<loc>http://www.mysite.com/-$data[0].html</loc><br />
<priority>0.90</priority><br />
<changefreq>daily</changefreq><br />
<lastmod>2008-09-02</lastmod><br />
</url><br />");
}
?>

And when run it shows:

http://www.mysite.com/-data.html
0.90
daily
2008-09-02
It echos everything but the xml tags (Which is what I need). Is there
a correct way of doing this or tricking it somehow?
It already is correct. Have a look at the source code in your browser.
The tags are all there.

Micha
Sep 5 '08 #2

P: n/a
On Sep 4, 5:27*pm, Michael Fesser <neti...@gmx.dewrote:
.oO(BryanA)
I have a site that I need to generate a sitemap for. It is way to big
for a desktop program to crawl or any of the online sites. It
technically only has 4 pages but it runs from a DB with a couple
thousand pages. My plan is to generate a giant sitemap with a php file
querying the database and copy and pasting into a real xml file but I
hit a problem. I have tried the following code but no matter what I do
it always seems to takeout the < and >
<?php
$db_host = "localhost";
$db_user = "name";
$db_pwd = "pass";
$db_name = "db name";
$con = mysql_connect($db_host, $db_user, $db_pwd);
mysql_select_db($db_name);
$result = mysql_query("SELECT * FROM db");
while($data = mysql_fetch_row($result)){
echo("
<url><br />
<loc>http://www.mysite.com/-$data[0].html</loc><br />
<priority>0.90</priority><br />
<changefreq>daily</changefreq><br />
<lastmod>2008-09-02</lastmod><br />
</url><br />");
}
?>
And when run it shows:
http://www.mysite.com/-data.html
0.90
daily
2008-09-02
It echos everything but the xml tags (Which is what I need). Is there
a correct way of doing this or tricking it somehow?

It already is correct. Have a look at the source code in your browser.
The tags are all there.

Micha
Wow do I feel stupid. I never even thought about that. Thanks a ton!
Sep 5 '08 #3

P: n/a
..oO(BryanA)
>On Sep 4, 5:27*pm, Michael Fesser <neti...@gmx.dewrote:
>>
It already is correct. Have a look at the source code in your browser.
The tags are all there.

Wow do I feel stupid. I never even thought about that. Thanks a ton!
You're welcome. ;)

Micha
Sep 5 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.