Re: Interaction between SimpleXML & DOM
- From: Toby A Inkster <usenet200801@xxxxxxxxxxxxxxxxx>
- Date: Wed, 20 Feb 2008 09:45:43 +0000
Lorenzo De Tomasi wrote:
$contentNode = $dom->importNode([$page->content->asXML()],
[?]);//I don't understand how to output the full tree under <content>
element in xml file. I have tried with childNodes, but it doesn't
work...
// Get list of all <content> elements in $page.
$contentNodes = $page->getElementsByTagName('content');
// Get first such <content> element. (There is probably only one.)
$contentNode = $contentNodes->item(0);
// For each child of <content>...
foreach ($contentNode->childNodes as $pageKid)
{
// Import it into $dom
$domKid = $dom->importNode($pageKid, 1);
// Add the imported node as a child of $body.
$body->appendChild($domKid);
}
--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 21 days, 15:57.]
Bottled Water
http://tobyinkster.co.uk/blog/2008/02/18/bottled-water/
.
- Follow-Ups:
- Re: Interaction between SimpleXML & DOM
- From: Lorenzo De Tomasi
- Re: Interaction between SimpleXML & DOM
- References:
- Interaction between SimpleXML & DOM
- From: Lorenzo De Tomasi
- Re: Interaction between SimpleXML & DOM
- From: Toby A Inkster
- Re: Interaction between SimpleXML & DOM
- From: Lorenzo De Tomasi
- Re: Interaction between SimpleXML & DOM
- From: Toby A Inkster
- Re: Interaction between SimpleXML & DOM
- From: Lorenzo De Tomasi
- Interaction between SimpleXML & DOM
- Prev by Date: Re: Different MSSQL output date format from the same PHP script
- Next by Date: how to configure PHP5 to use MySQL in Windows XP
- Previous by thread: Re: Interaction between SimpleXML & DOM
- Next by thread: Re: Interaction between SimpleXML & DOM
- Index(es):
Relevant Pages
|