Re: appendChild help?
Brought to you by:
bs_php,
nigelswinson
From: Nigel S. <nig...@us...> - 2001-11-06 14:03:58
|
> Could someone give me a simple example of appending a child to a node. > > e.g. > > file contents are <root></root> > $xml = new XPath("$filename"); > $xml->appendData("/root[1]", "blah" ); > > What do I put in instead of "blah" to add a node called blah? Erm, that should work. You should get: <root><blah/></root> Don't you? How do you know you don't? Perhaps mail round example xml file and php script? > I've been trying to figure this out too. The only way can do it is to > appendChild() then appendData() into that child. > > $xml->appendChild("/root[1]", "newchild"); > $xml->appendData("/root[1]/newchild[1]", "some new data here"); > > It would be nice to be able to to this in one step. > > Any help appreciated. It's on it's way. Soon you'll be able to do: appendChild("/root[1]","<newchild>some new data here</newchild>"); Nigel =========================== For the most recent version of Php.XPath, V2.x, and an archive of this list visit: http://www.sourceforge.net/projects/phpxpath |