note 99818 added to domdocument.validate

From: Date: Wed, 08 Sep 2010 19:46:45 +0000
Subject: note 99818 added to domdocument.validate
Groups: php.notes 
Request: Send a blank email to php-notes+get-172384@lists.php.net to get a copy of this message
I was trying to validate my SVG file just to get the IDs with getElementById(), <?xml version="1.0"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <text id="text_titulo" x="150" y="20" font-family="Arial" font-size="15px" style="font-weight:bold;">Title</text> <text id="text_subtitulo" x="200" y="35" font-family="Arial" font-size="10px">Sub Title</text> <g transform="translate(0,50) scale(0.1)"> <a id="a_AC" ...... > <polygon id="polygon_AC" ....... /> </a> </g> </svg> but when calling $dom->load(), it was getting the errors "failed to open stream" and "Validation failed: no DTD found !I/O warning : failed to load external entity" so I created my own validation wrapper (I just want to find the IDs with getElementById() ) <?php $docSVG = new DOMDocument(); $docSVG->load(realpath($filepath)); setAllId($docSVG); function setAllId($DOMNode){ if($DOMNode->hasChildNodes()){ foreach ($DOMNode->childNodes as $DOMElement) { if($DOMElement->hasAttributes()){ $id=$DOMElement->getAttribute("id"); if($id){ $DOMElement->setIdAttribute("id",$id); } } setAllId($DOMElement); } } } ?> ---- Server IP: 189.126.97.120 Probable Submitter: 189.40.216.70 ---- Manual Page -- http://www.php.net/manual/en/domdocument.validate.php Edit -- https://master.php.net/note/edit/99818 Del: integrated -- https://master.php.net/note/delete/99818/integrated Del: useless -- https://master.php.net/note/delete/99818/useless Del: bad code -- https://master.php.net/note/delete/99818/bad+code Del: spam -- https://master.php.net/note/delete/99818/spam Del: non-english -- https://master.php.net/note/delete/99818/non-english Del: in docs -- https://master.php.net/note/delete/99818/in+docs Del: other reasons-- https://master.php.net/note/delete/99818 Reject -- https://master.php.net/note/reject/99818 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#172384) next »