hi,
I am new to php and although php has xml support i am not using it cause i am not too familiar with it
i created a simple php script that writes information from a form to an xml file using fwrite()
the outputstring is as follows
---file--
<?xml version="1.0" encoding="iso-8859-1"?>
<guestbook>
</guestbook>
--endfile--
---code----
$data = "<guest date=\"date('jS F Y')\">\n"."<name>\n".$_POST[Name]."</name>\n"."<email>\n".$_POST[Email]."</email>\n"."<comments>\n".$_POST[Comments]."</comments>\n"."</guest>\n"."</guestbook>";
$file = str_replace("</guestbook>",$data,$file);
---end ----
then i write the file
however in tryin to view the xml file i get nuthing and viewing the source code reveals html content
can i just write to the xml file withou any php/cml functions?
writing to an XML with PHP
Moderator: General Moderators
- kendall
- Forum Regular
- Posts: 852
- Joined: Tue Jul 30, 2002 10:21 am
- Location: Trinidad, West Indies
- Contact:
guest book using PHP and XMl
well i dont know yet i was thinking of having php do dat but my first step was getting it to write to the xml file
the code shown was something i thought i cud have done. I mean to say i am using the theory as if it were a text file
is this possible to just fread() the xml file to a variable and then just spit it back out to the browser once i do a formatting code in php
thus waht i am saying is this
let say i have the xmlf file <guestbook>this is text</guestbook> php freads it
and i use a replace code to replace xml tags with html tags and wallah spit it back out to the browser like normal
cant that work without the xml api mumbo jumbo?
Kendall
the code shown was something i thought i cud have done. I mean to say i am using the theory as if it were a text file
is this possible to just fread() the xml file to a variable and then just spit it back out to the browser once i do a formatting code in php
thus waht i am saying is this
let say i have the xmlf file <guestbook>this is text</guestbook> php freads it
and i use a replace code to replace xml tags with html tags and wallah spit it back out to the browser like normal
cant that work without the xml api mumbo jumbo?
Kendall
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact: