OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   Re: [xml-dev] XML with PHP

[ Lists Home | Date Index | Thread Index ]

3/5/2002 11:52:21 AM, "Marksman" <chris_ziel@yahoo.de> wrote:

>    i want to build a page with server-side parsed XML.
>    Bit i dont know how to use XML with PHP.

Here are a few resources I found interesting/useful.  They
are totally DOM-centric ... although
the PHP DOM interface is highly non-standard.


The "user contributed notes" are the most useful part of the manual!


Here's a trivial php program that takes a POST of an HTML form
(the names of the fields are automatically represented as PHP
variables), opens an RSS-like file identified by the $file value,
and puts the form information in a new "item" element at the bottom
of the first "channel" element, then rewrites the file and echoes
its contents to the browser. 


  header ("content-type: text/xml");

    	$file = "http://localhost/log/"; . $arch . ".xml";
    	$doc = xmldocfile($file);

      $r = $c->nodeset[0];
	$i = $r->new_child("item");
	$i->new_child("title", $head);
	$i->new_child("link", $link);
	$i->new_child("description", $comment);

    	$out = domxml_dumpmem($doc);
    	$file = $arch . ".xml";
    	$f = fopen($file, 'w');
    	fputs($f, $out);

	echo $out;

I am a complete PHP novice, so any
suggestions to do things in a more sensible way would be appreciated.

  • References:


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS