Validating XML Issue

Validating XML Issue

am 03.09.2009 16:26:21 von Alice Wei

--_df538e18-9495-4c63-872f-f996a281c251_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


Hi,

This seems like a small problem that I have read from http://us.php.net/m=
anual/en/xmlreader.isvalid.php.=20
I have the code snippet here as follows:

$xml =3D XMLReader::open('hello.xml')=3B

// You must to use it
$xml->setParserProperty(XMLReader::VALIDATE=2C true)=3B

if ($xml->isValid()) echo "true"=3B
else echo "NOT"=3B

?>

Here is the contents of hello.xml:

Hello

Obviously=2C this is not a well formed XML file.=20

However=2C whenever I run the PHP code=2C it returns true=2C how do I get i=
t to validate it the way it is supposed to be?=20

Thanks for your help.=20

Alice




____________________________________________________________ _____
Search from any Web page with powerful protection. Get the FREE Windows Liv=
e Toolbar Today!
http://get.live.com/toolbar/overview=

--_df538e18-9495-4c63-872f-f996a281c251_--

Re: Validating XML Issue

am 03.09.2009 16:42:00 von Mattias Thorslund

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:
>
> > $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:
>
> 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

RE: Validating XML Issue

am 03.09.2009 18:52:11 von Alice Wei

--_b82b6298-2642-4952-8b0b-aa620b9e97da_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


Hi,



Thanks for trying to help me out. I don't have a schema for my XML=2C bu=
t here is something cool I found that worked for me: http://www.w3schools.c=
om/PHP/func_xml_error_string.asp

Alice

> Date: Thu=2C 3 Sep 2009 07:42:00 -0700
> From: mattias@thorslund.us
> To: ajwei@alumni.iu.edu
> CC: php-general@lists.php.net
> Subject: Re: [PHP] Validating XML Issue
>=20
> I'd say your XML document is not "well formed"=2C but validity depends on=
=20
> whether it conforms to the rules expressed in a schema.
>=20
> Mattias
>=20
> Alice Wei wrote:
> > Hi,
> >
> > This seems like a small problem that I have read from http://us.php.n=
et/manual/en/xmlreader.isvalid.php.=20
> > I have the code snippet here as follows:
> >
> > > > $xml =3D XMLReader::open('hello.xml')=3B
> >
> > // You must to use it
> > $xml->setParserProperty(XMLReader::VALIDATE=2C true)=3B
> >
> > if ($xml->isValid()) echo "true"=3B
> > else echo "NOT"=3B
> >
> > ?>
> >
> > Here is the contents of hello.xml:
> >
> > Hello
> >
> > Obviously=2C this is not a well formed XML file.=20
> >
> > However=2C whenever I run the PHP code=2C it returns true=2C how do I g=
et it to validate it the way it is supposed to be?=20
> >
> > Thanks for your help.=20
> >
> > Alice
> >
> >
> >
> >
> > ____________________________________________________________ _____
> > Search from any Web page with powerful protection. Get the FREE Windows=
Live Toolbar Today!
> > http://get.live.com/toolbar/overview
> > =20
>=20
>=20

____________________________________________________________ _____
All-in-one security and maintenance for your PC.=A0 Get a free 90-day trial=
!
http://www.windowsonecare.com/purchase/trial.aspx?sc_cid=3Dw l_wlmail=

--_b82b6298-2642-4952-8b0b-aa620b9e97da_--