XML DOM
XML ??
XML ??? ?? ????(?? ? ??)??? XML ??? ?????.
XML ???? ? ?? ?? ??? ????.
· ?? ?? ??: ? ??? XML ??? ?? ??? ?????. ?? ??? ???? DOM(?? ?? ??)? ?? ??? ??? ?? ???? ?????.
· ?? ?? ??: XML ??? ??? ???? ?????. ?? ???? ???? ??? ?? ???? ??? ?????.
DOM ??? ?? ?? ?????.
?? XML ?? ??? ?????.
<?xml version="1.0" ???="ISO-8859-1"?>
<from>Jani< /from>
XML DOM ?? XML? ?? ??? ?????:
· ?? 1: XML ??
· ?? 2: ?? ??: <from> ;
· ?? 3: ??? ??: "Jani"
??
DOM XML ?? ??? PHP ??? ?????. ? ??? ???? ?? ??? ???? ????.
XML ??
? ???? ?? XML ??? ?????:
<?xml version="1.0" encoding="ISO-8859-1"?> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>
XML ?? ? ??
XML ??? ????? XML? ??? ? ???? ???.
Instance
<?php $xmlDoc = new DOMDocument(); $xmlDoc->load("note.xml"); print $xmlDoc->saveXML(); ?>
? ??? ?? :
ToveJaniReminder ?? ??? ?? ?? ???!
???? ??? ?? ??? ?? ?? HTML? ? ? ????:
<?xml version="1.0" encoding="ISO-8859-1"?> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>
? ?? DOMDocument-Object? ???? "note.xml"? XML? ? ?? ??? ?????.
saveXML() ??? ?? XML ??? ???? ???? ??? ? ??? ???.
XML ??
XML ??? ????? XML? ???? ????? ???. <??> ; ??? ?? ??:
????
<?php $xmlDoc = new DOMDocument(); $xmlDoc->load("note.xml"); $x = $xmlDoc->documentElement; foreach ($x->childNodes AS $item) { print $item->nodeName . " = " . $item->nodeValue . "<br>"; } ?>
? ??? ??? ?????:
#text =
to = Tove
# text =
from = Jani
#text =
header = ??
#text =
body = ?? ??? ?? ?? ???!
#text =
?? ???? ? ?? ??? ? ??? ??? ?? ?? ? ? ????.
XML? ???? ????? ?? ??? ??? ?????. XML DOM ??? ?? ?? ??? ????? ??? ???? ??? ??? ??? ? ????.