Re: [PHP] Validating XML Issue
I'd say your XML document is not well formed, but validity depends on whether it conforms to the rules expressed in a schema. Mattias Alice Wei wrote: Hi, This seems like a small problem that I have read from http://us.php.net/manual/en/xmlreader.isvalid.php. I have the code snippet here as follows: ?php $xml = XMLReader::open('hello.xml'); // You must to use it $xml-setParserProperty(XMLReader::VALIDATE, true); if ($xml-isValid()) echo true; else echo NOT; ? Here is the contents of hello.xml: greetinghelloHello/hello Obviously, this is not a well formed XML file. However, whenever I run the PHP code, it returns true, how do I get it to validate it the way it is supposed to be? Thanks for your help. Alice _ Search from any Web page with powerful protection. Get the FREE Windows Live Toolbar Today! http://get.live.com/toolbar/overview -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Validating XML Issue
Hi, This seems like a small problem that I have read from http://us.php.net/manual/en/xmlreader.isvalid.php. I have the code snippet here as follows: ?php $xml = XMLReader::open('hello.xml'); // You must to use it $xml-setParserProperty(XMLReader::VALIDATE, true); if ($xml-isValid()) echo true; else echo NOT; ? Here is the contents of hello.xml: greetinghelloHello/hello Obviously, this is not a well formed XML file. However, whenever I run the PHP code, it returns true, how do I get it to validate it the way it is supposed to be? Thanks for your help. Alice _ Search from any Web page with powerful protection. Get the FREE Windows Live Toolbar Today! http://get.live.com/toolbar/overview
RE: [PHP] Validating XML Issue
Hi, Thanks for trying to help me out. I don't have a schema for my XML, but here is something cool I found that worked for me: http://www.w3schools.com/PHP/func_xml_error_string.asp Alice Date: Thu, 3 Sep 2009 07:42:00 -0700 From: matt...@thorslund.us To: aj...@alumni.iu.edu CC: php-general@lists.php.net Subject: Re: [PHP] Validating XML Issue I'd say your XML document is not well formed, but validity depends on whether it conforms to the rules expressed in a schema. Mattias Alice Wei wrote: Hi, This seems like a small problem that I have read from http://us.php.net/manual/en/xmlreader.isvalid.php. I have the code snippet here as follows: ?php $xml = XMLReader::open('hello.xml'); // You must to use it $xml-setParserProperty(XMLReader::VALIDATE, true); if ($xml-isValid()) echo true; else echo NOT; ? Here is the contents of hello.xml: greetinghelloHello/hello Obviously, this is not a well formed XML file. However, whenever I run the PHP code, it returns true, how do I get it to validate it the way it is supposed to be? Thanks for your help. Alice _ Search from any Web page with powerful protection. Get the FREE Windows Live Toolbar Today! http://get.live.com/toolbar/overview _ All-in-one security and maintenance for your PC. Get a free 90-day trial! http://www.windowsonecare.com/purchase/trial.aspx?sc_cid=wl_wlmail
[PHP] Validating XML
Hello, Anyone have pointers to good tutorials out there for validating XML with DTD? I have looked at the top comment on: http://www.php.net/manual/en/ref.xmlreader.php#xmlreader.constants Where you set the parser property to validate, but it is kind of like a black box...what is it using the validate the XML schema? I am working with an XML document and a DTD file which is separate, do the files have to share a name with a different extension, or does the DTD somehow have to be embedded? TIA -Brad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Validating XML structure with PHP
Hi, I want to validate an XML structure using PHP. I thought of using PHP's DOM and XSD or DTD for validation. This does the job ok, except on invalid XML structure I get the same error code. What I want is to point exactly why the XML structure is invalid. I know there's also an error message that gives a bit more precision on the cause, but it's not something I can show the user. Is there another way to validate XML structure (that can give a precise error cause, like missing element, invalid element value, etc)? -thanks, Eli -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Validating XML Schema
Hi, I am trying to use php to validate a document using it's schema. I keep getting Warning: Element 'Invoices': No matching global declaration available. My xsd has ?xml version=1.0 ? xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema; targetNamespace=http://www.mysite.com; xmlns=http://www.mysite.com; elementFormDefault=qualified xs:element name=Invoices type=InvoicesType/ xs:complexType name=InvoicesType xs:element name=Invoice type=xs:string/ /xs:complexType /xs:schema The xml test ?xml version=1.0 ? Invoices Invoice10/Invoice /Invoices The php $xml = new DOMDocument(); $xml-load( 'invoice.xml' ); if ($xml-schemaValidate(invoice.xsd)) { echo Validated OK ; } else { echo Validate FAILED; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Validating XML strings
I am parsing an xml string using the DOM package in php. Is there anyway to validate the xml string against a schema or a dtd with DOM. I know it is still experimental but I didn't know if something like that existed. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Validating XML strings
As of now i dont think that DOMXML functions support the validation of dtds or schemas...I have been looking for the past couple of days and did not find anything... I have not verified the xml extension for it but i doubt that that option is there either... -- BigDog On Tue, 2003-07-01 at 14:00, Moore, Christie wrote: I am parsing an xml string using the DOM package in php. Is there anyway to validate the xml string against a schema or a dtd with DOM. I know it is still experimental but I didn't know if something like that existed. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php