|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-07-03 04:33 UTC] grest at interia dot pl
Description: ------------ get_element_by_id doesn`t work and always returns NULL. Reproduce code: --------------- MY DTD: <?xml version="1.0" encoding="UTF-8"?> <!ELEMENT LIST (MOVIE+)> <!ELEMENT MOVIE (TITLE, ORGTITLE, LOC, INFO)> <!ATTLIST MOVIE ID ID #REQUIRED > <!ELEMENT TITLE (#PCDATA)> <!ELEMENT ORGTITLE (#PCDATA)> <!ELEMENT LOC (#PCDATA)> <!ELEMENT INFO (#PCDATA)> PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 22:00:02 2025 UTC |
$fileName = "filmy.xml"; $fid = $HTTP_POST_VARS['deltitle']; if(!$dom = domxml_open_file($fileName)) { echo "Error while parsing the document\n"; exit; } $node = $dom->get_element_by_id($fid); $parent = $node->parent_node(); $delnode = $parent->remove_child($node); $dom->dump_file("filmy.xml", true);del.php <?php $fileName = "filmy.xml"; $fid = $HTTP_POST_VARS['deltitle']; if(!$dom = domxml_open_file($fileName)) { echo "Error while parsing the document\n"; exit; } $node = $dom->get_element_by_id($fid); $parent = $node->parent_node(); $delnode = $parent->remove_child($node); $dom->dump_file("filmy.xml", true); $filename = "filmy.xsl"; $xmldoc = domxml_open_file("filmy.xml"); $xsldoc = domxml_xslt_stylesheet_file($filename); $result = $xsldoc->process($xmldoc); print $xsldoc->result_dump_mem($result); ?> filmy.xml: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE LIST SYSTEM "filmy.dtd"> <LIST> <MOVIE ID="m20036271138360"> <TITLE>13 Duch?w</TITLE> <ORGTITLE/><LOC>Grzesiek HDD</LOC> <INFO/> </MOVIE> <MOVIE ID="m20036271138361"> <TITLE>8 kobiet</TITLE> <ORGTITLE/> <LOC>Grzesiek HDD</LOC> <INFO/> </MOVIE> </LIST> simply.html: <html> <body> <form action="del.php" method="post" style="margin:0px"> <input type="hidden" name="deltitle" size="1" value="m20036271138360"><input type="image" name="Delete" src="del.gif"> </form> </body> </html> I`m sure that 'deltitle' and $fid variable are correct "connected" (sorry for my English :P ), but get_element_by_id doesn`t find the node in XML file(filmy.xml)Your xml is not valid: # /usr/bin/xmllint filmy.xml filmy.xml:5: error: Input is not proper UTF-8, indicate encoding ! <TITLE>13 Duch?w</TITLE> ^ filmy.xml:5: error: Bytes: 0xF3 0x77 0x3C 0x2F <TITLE>13 Duch?w</TITLE> ^I have installed PHP as Apache 2.0.46 module (earlier i used OmniHttp). That caused two problems: 1. The functions like domxml_open_file,domxml_xslt_stylesheet_file need now full path to work, for example $filename = "d:\Www\grugar\filmy.xsl"; $xmldoc = domxml_open_file("d:\Www\grugar\filmy.xml",DOMXML_LOAD_VALIDATING); earlier it works fine with $filename = "filmy.xsl" Another function like "fopen" work good without full path 2. (MOST IMPORTANT) get_element_by_id stoped working, and return always null (earlier with OmniHttp that works fine) Is this a bug or not? I don`t know, which category of bug should i choose. Sorry for my English :)Little mistake in line 5. Once again: I try various path in filmy.xml to dtd file, like: <!DOCTYPE LIST SYSTEM "D:\WWW\grugar\filmy.dtd"> <!DOCTYPE LIST SYSTEM "D:/WWW/grugar/filmy.dtd"> <!DOCTYPE LIST SYSTEM "\\Serwer\WWW\grugar\filmy.dtd"> <!DOCTYPE LIST SYSTEM "d:/www/grugar/filmy.dtd"> and none of them works !! How should this path look?! For example the path in XSL file (filmy.xsl) works: filmy.xsl ... <xsl:variable name="out" select="document('d:/www/grugar/today.xml')"/> ...When I use in XSL file(filmy.xsl) just <xsl:variable name="out" select="document('today.xml')"/> it works fine. I needn`t to insert a full path('d:\www\grugar\today.xml') In XML it doesn`t work. I use: <!DOCTYPE LIST SYSTEM "filmy.dtd"> or <!DOCTYPE LIST SYSTEM "d:/www/grugar/filmy.dtd"> and always when I use get_element_by_id, I get a NULL! I`m sure that XML is not validated with filmy.dtd. I tested XML with two identical id (without error while loading!) or insert a mistakes into filmy.dtd and the domxml_open_file($fileName, DOMXML_LOAD_VALIDATING)does NOT return any errors or warnings. Conclusion: "filmy.dtd" is not loaded. Earlier, in similar case domxml_open_file returns error.