Created
September 10, 2016 19:35
-
-
Save cmb69/a98d1b784ff536393bd8e9cead5fd0e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<x:books xmlns:x="urn:books"> | |
<book id="1"> | |
<author>Writer</author> | |
<title>The First Book</title> | |
<genre>Fiction</genre> | |
<price>44.95</price> | |
<pub_date>2000-10-01</pub_date> | |
<review>An amazing story of nothing.</review> | |
</book> | |
</x:books> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" | |
targetNamespace="urn:books" | |
xmlns:bks="urn:books"> | |
<xsd:element name="books" type="bks:BooksForm"/> | |
<xsd:complexType name="BooksForm"> | |
<xsd:sequence> | |
<xsd:element name="book" | |
type="bks:BookForm" | |
minOccurs="0" | |
maxOccurs="unbounded"/> | |
</xsd:sequence> | |
</xsd:complexType> | |
<xsd:complexType name="BookForm"> | |
<xsd:sequence> | |
<xsd:element name="author" type="xsd:string"/> | |
<xsd:element name="title" type="xsd:string"/> | |
<xsd:element name="genre" type="xsd:string"/> | |
<xsd:element name="price" type="xsd:float" /> | |
<xsd:element name="pub_date" type="xsd:date" /> | |
<xsd:element name="review" type="xsd:string"/> | |
</xsd:sequence> | |
<xsd:attribute name="id" type="xsd:positiveInteger"/> | |
</xsd:complexType> | |
</xsd:schema> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$xmlfile = __DIR__ . DIRECTORY_SEPARATOR . 'books.xml'; | |
$xsdfile = __DIR__ . DIRECTORY_SEPARATOR . 'books.xsd'; | |
$xml = new XMLReader(); | |
if(!$xml->open($xmlfile, null, LIBXML_PARSEHUGE)){ | |
logging('Unable to Open XML file (Full Parse 1):' . $xmlfile); | |
return false; | |
} | |
$xml->setSchema($xsdfile); | |
while($xml->read()){ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment