NYCPHP Meetup

NYPHP.org

[nycphp-talk] About XML in PHP

Jon Baer jonbaer at jonbaer.net
Thu Dec 2 00:55:58 EST 2004


im not sure you really want a parser function as much as you want to 
manipulate + outout the dom .. check out dom functions:

http://www.php.net/dom

example: (you can also load/modify/etc)

<?php
$doc = new DOMDocument("1.0");
$foo = $doc->createElement("foo");
$foo = $doc->appendChild($foo);
$bar = $doc->createElement("bar", "NYPHP Talk");
$bar = $foo->appendChild($bar);
echo $doc->saveXML();
?>

output:

<?xml version="1.0"?>
<foo><bar>NYPHP Talk</bar></foo>

- jon

Amir Aavani wrote:
> dear friends
> i have a question about XML support in PHP. is there any class or
> function or etc that allow the program to generate an XML
> file(stream).I mean that it can add new node or new element or
> atrribute by its input parameters.
> for example if in its input, there is a 'login' message , it can add a
> node 'Login' to its output XML, and in otherwise add a node 'not
> login' or something like this.
> i know that there are some parser function or classes in PHP but with
> none of them you can't add a new node to the output XML.
> thanks
> Amir

pgp key: http://www.jonbaer.net/jonbaer.asc
fingerprint: F438 A47E C45E 8B27 F68C 1F9B 41DB DB8B 9A0C AF47



More information about the talk mailing list