Pessoall ,
Eu preciso validar um xml usando um schema
alguem sabe como fazer isso ???
grato se alguem souber …
Pessoall ,
Eu preciso validar um xml usando um schema
alguem sabe como fazer isso ???
grato se alguem souber …
Dae brother,
Vai um exemplo pra ajudar.
Referenciando um schema("note.xsd") neste xml:
<?xml version="1.0"?>
<note xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3schools.com note.xsd">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
Para este schema ( Salvo com o nome de "note.xsd"):
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com"
elementFormDefault="qualified">
<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Tem um tutorial muito bom nesta pagina
http://www.dicas-l.unicamp.br/dicas-l/20050326.php
Espero ter ajudado.
Falow