<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >XMLReader functions</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="Manual do PHP" HREF="index.html"><LINK REL="UP" TITLE="Referência das Funções" HREF="funcref.html"><LINK REL="PREVIOUS" TITLE="xmlrpc_set_type" HREF="function.xmlrpc-set-type.html"><LINK REL="NEXT" TITLE="XMLReader::close" HREF="function.xmlreader-close.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="reference" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Manual do PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.xmlrpc-set-type.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.xmlreader-close.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="reference" ><A NAME="ref.xmlreader" ></A ><DIV CLASS="TITLEPAGE" ><H1 CLASS="title" >CLXXXI. XMLReader functions</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN235412" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="xmlreader.intro" >Introdução</A ></H1 ><P > The XMLReader extension is an XML Pull parser. The reader acts as a cursor going forward on the document stream and stopping at each node on the way. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="xmlreader.installation" >Instalação</A ></H1 ><P > The XMLReader extension is available in PECL as of PHP 5.0.0 and is included and enabled as of PHP 5.1.0 by default. It can be enabled by adding the argument <CODE CLASS="option" >--enable-xmlreader</CODE > (or <CODE CLASS="option" >--with-xmlreader</CODE > before 5.1.0) to your configure line. The <A HREF="ref.libxml.html" >libxml</A > extension is required. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="xmlreader.classes" >Classes pré-definidas</A ></H1 ><P > </P ><DIV CLASS="section" ><H2 CLASS="section" ><A NAME="xmlreader.class.xmlreader" ><B CLASS="classname" >XMLReader</B ></A ></H2 ><P > </P ><DIV CLASS="section" ><H3 CLASS="section" ><A NAME="xmlreader.class.xmlreader.methods" >Métodos</A ></H3 ><P ></P ><UL ><LI ><P ><A HREF="function.xmlreader-close.html" >XMLReader::close</A > - Close the XMLReader input</P ></LI ><LI ><P ><A HREF="function.xmlreader-expand.html" >XMLReader::expand</A > - Export current node to a DOM node</P ></LI ><LI ><P ><A HREF="function.xmlreader-getattribute.html" >XMLReader::getAttribute</A > - Get value of attribute by name</P ></LI ><LI ><P ><A HREF="function.xmlreader-getattributeno.html" >XMLReader::getAttributeNo</A > - Get value of attribute by position</P ></LI ><LI ><P ><A HREF="function.xmlreader-getattributens.html" >XMLReader::getAttributeNs</A > - Get value of attribute by name and URI</P ></LI ><LI ><P ><A HREF="function.xmlreader-getparserproperty.html" >XMLReader::getParserProperty</A > - Indicates if parser property is set or not</P ></LI ><LI ><P ><A HREF="function.xmlreader-isvalid.html" >XMLReader::isValid</A > - Indicates if document is valid</P ></LI ><LI ><P ><A HREF="function.xmlreader-lookupnamespace.html" >XMLReader::lookupNamespace</A > - Get URI for prefix in scope of node</P ></LI ><LI ><P ><A HREF="function.xmlreader-movetoattribute.html" >XMLReader::moveToAttribute</A > - Positions reader on named attribute</P ></LI ><LI ><P ><A HREF="function.xmlreader-movetoattributeno.html" >XMLReader::moveToAttributeNo</A > - Positions reader on attribute by index</P ></LI ><LI ><P ><A HREF="function.xmlreader-movetoattributens.html" >XMLReader::moveToAttributeNs</A > - Position reader on attribute by name and URI</P ></LI ><LI ><P ><A HREF="function.xmlreader-movetoelement.html" >XMLReader::moveToElement</A > - Move to parent element of current attribute node</P ></LI ><LI ><P ><A HREF="function.xmlreader-movetofirstattribute.html" >XMLReader::moveToFirstAttribute</A > - Move to first attribute of node</P ></LI ><LI ><P ><A HREF="function.xmlreader-movetonextattribute.html" >XMLReader::moveToNextAttribute</A > - Move to next attribute of node</P ></LI ><LI ><P ><A HREF="function.xmlreader-next.html" >XMLReader::next</A > - Move to next element skipping children</P ></LI ><LI ><P ><A HREF="function.xmlreader-open.html" >XMLReader::open</A > - Set URI to be parsed</P ></LI ><LI ><P ><A HREF="function.xmlreader-read.html" >XMLReader::read</A > - Move to next node in stream</P ></LI ><LI ><P ><A HREF="function.xmlreader-setparserproperty.html" >XMLReader::setParserProperty</A > - Set parser property</P ></LI ><LI ><P ><A HREF="function.xmlreader-setrelaxngschema.html" >XMLReader::setRelaxNGSchema</A > - Set URI of RelaxNG schema to validate against</P ></LI ><LI ><P ><A HREF="function.xmlreader-setrelaxngschemasource.html" >XMLReader::setRelaxNGSchemaSource</A > - Set string containing RelaxNG schema to validate against</P ></LI ><LI ><P ><A HREF="function.xmlreader-xml.html" >XMLReader::XML</A > - Set string of data to be parsed</P ></LI ></UL ></DIV ><DIV CLASS="section" ><H3 CLASS="section" ><A NAME="xmlreader.class.xmlreader.properties" >Propriedades</A ></H3 ><DIV CLASS="table" ><A NAME="AEN235497" ></A ><P ><B >Tabela 1. </B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><COL><COL><COL><COL><THEAD ><TR ><TH >Name</TH ><TH >Type</TH ><TH >Read-only</TH ><TH >Description</TH ></TR ></THEAD ><TBODY ><TR ><TD >attributeCount</TD ><TD >int</TD ><TD >yes</TD ><TD >The number of attributes on the node</TD ></TR ><TR ><TD >baseURI</TD ><TD >string</TD ><TD >yes</TD ><TD >The base URI of the node</TD ></TR ><TR ><TD >depth</TD ><TD >int</TD ><TD >yes</TD ><TD >Depth of the node in the tree starting at 0</TD ></TR ><TR ><TD >hasAttributes</TD ><TD >bool</TD ><TD >yes</TD ><TD >Indicates if node has attributes</TD ></TR ><TR ><TD >hasValue</TD ><TD >bool</TD ><TD >yes</TD ><TD >Indicates if node has a text value</TD ></TR ><TR ><TD >isDefault</TD ><TD >bool</TD ><TD >yes</TD ><TD >Indicates if attribute is defaulted from DTD</TD ></TR ><TR ><TD >isEmptyElement</TD ><TD >bool</TD ><TD >yes</TD ><TD >Indicates if node is an empty element tag</TD ></TR ><TR ><TD >localName</TD ><TD >string</TD ><TD >yes</TD ><TD >The local name of the node</TD ></TR ><TR ><TD >name</TD ><TD >string</TD ><TD >yes</TD ><TD >The qualified name of the node</TD ></TR ><TR ><TD >namespaceURI</TD ><TD >string</TD ><TD >yes</TD ><TD >The URI of the namespace associated with the node</TD ></TR ><TR ><TD >nodeType</TD ><TD >int</TD ><TD >yes</TD ><TD >The node type for the node</TD ></TR ><TR ><TD >prefix</TD ><TD >string</TD ><TD >yes</TD ><TD >The prefix of the namespace associated with the node</TD ></TR ><TR ><TD >value</TD ><TD >string</TD ><TD >yes</TD ><TD >The text value of the node</TD ></TR ><TR ><TD >xmlLang</TD ><TD >string</TD ><TD >yes</TD ><TD >The xml:lang scope which the node resides</TD ></TR ></TBODY ></TABLE ></DIV ></DIV ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="xmlreader.constants" >Constantes pré-definidas</A ></H1 ><P > As contantes abaixo são definidas por esta extensão e somente estarão disponíveis quando a extensão foi compilada com o PHP ou carregada dinamicamente durante a execução. </P ><DIV CLASS="warning" ><P ></P ><TABLE CLASS="warning" BORDER="1" WIDTH="100%" ><TR ><TD ALIGN="CENTER" ><B >Atenção</B ></TD ></TR ><TR ><TD ALIGN="LEFT" ><P > XMLReader uses class constants since PHP 5.1. Prior releases use global constants in the form <TT CLASS="constant" ><B >XMLREADER_ELEMENT</B ></TT >. </P ></TD ></TR ></TABLE ></DIV ><DIV CLASS="table" ><A NAME="AEN235583" ></A ><P ><B >Tabela 2. XMLReader Node Types</B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><COL><COL><COL><THEAD ><TR ><TH >Constant</TH ><TH >Value</TH ><TH >Description</TH ></TR ></THEAD ><TBODY ><TR ><TD > <TT CLASS="constant" ><B >XMLReader::NONE</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >) </TD ><TD >0</TD ><TD >No node type</TD ></TR ><TR ><TD > <TT CLASS="constant" ><B >XMLReader::ELEMENT</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >) </TD ><TD >1</TD ><TD >Start element</TD ></TR ><TR ><TD > <TT CLASS="constant" ><B >XMLReader::ATTRIBUTE</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >) </TD ><TD >2</TD ><TD >Attribute node</TD ></TR ><TR ><TD > <TT CLASS="constant" ><B >XMLReader::TEXT</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >) </TD ><TD >3</TD ><TD >Text node</TD ></TR ><TR ><TD > <TT CLASS="constant" ><B >XMLReader::CDATA</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >) </TD ><TD >4</TD ><TD >CDATA node</TD ></TR ><TR ><TD > <TT CLASS="constant" ><B >XMLReader::ENTITY_REF</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >) </TD ><TD >5</TD ><TD >Entity Reference node</TD ></TR ><TR ><TD > <TT CLASS="constant" ><B >XMLReader::ENTITY</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >) </TD ><TD >6</TD ><TD >Entity Declaration node</TD ></TR ><TR ><TD > <TT CLASS="constant" ><B >XMLReader::PI</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >) </TD ><TD >7</TD ><TD >Processing Instruction node</TD ></TR ><TR ><TD > <TT CLASS="constant" ><B >XMLReader::COMMENT</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >) </TD ><TD >8</TD ><TD >Comment node</TD ></TR ><TR ><TD > <TT CLASS="constant" ><B >XMLReader::DOC</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >) </TD ><TD >9</TD ><TD >Document node</TD ></TR ><TR ><TD > <TT CLASS="constant" ><B >XMLReader::DOC_TYPE</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >) </TD ><TD >10</TD ><TD >Document Type node</TD ></TR ><TR ><TD > <TT CLASS="constant" ><B >XMLReader::DOC_FRAGMENT</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >) </TD ><TD >11</TD ><TD >Document Fragment node</TD ></TR ><TR ><TD > <TT CLASS="constant" ><B >XMLReader::NOTATION</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >) </TD ><TD >12</TD ><TD >Notation node</TD ></TR ><TR ><TD > <TT CLASS="constant" ><B >XMLReader::WHITESPACE</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >) </TD ><TD >13</TD ><TD >Whitespace node</TD ></TR ><TR ><TD > <TT CLASS="constant" ><B >XMLReader::SIGNIFICANT_WHITESPACE</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >) </TD ><TD >14</TD ><TD >Significant Whitespace node</TD ></TR ><TR ><TD > <TT CLASS="constant" ><B >XMLReader::END_ELEMENT</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >) </TD ><TD >15</TD ><TD >End Element</TD ></TR ><TR ><TD > <TT CLASS="constant" ><B >XMLReader::END_ENTITY</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >) </TD ><TD >16</TD ><TD >End Entity</TD ></TR ><TR ><TD > <TT CLASS="constant" ><B >XMLReader::XML_DECLARATION</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >) </TD ><TD >17</TD ><TD >XML Declaration node</TD ></TR ></TBODY ></TABLE ></DIV ><DIV CLASS="table" ><A NAME="AEN235700" ></A ><P ><B >Tabela 3. XMLReader Parser Options</B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><COL><COL><COL><THEAD ><TR ><TH >Constant</TH ><TH >Value</TH ><TH >Description</TH ></TR ></THEAD ><TBODY ><TR ><TD > <TT CLASS="constant" ><B >XMLReader::LOADDTD</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >) </TD ><TD >1</TD ><TD >Load DTD but do not validate</TD ></TR ><TR ><TD > <TT CLASS="constant" ><B >XMLReader::DEFAULTATTRS</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >) </TD ><TD >2</TD ><TD >Load DTD and default attributes but do not validate</TD ></TR ><TR ><TD > <TT CLASS="constant" ><B >XMLReader::VALIDATE</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >) </TD ><TD >3</TD ><TD >Load DTD and validate while parsing</TD ></TR ><TR ><TD > <TT CLASS="constant" ><B >XMLReader::SUBST_ENTITIES</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >) </TD ><TD >4</TD ><TD >Substitute entities and expand references</TD ></TR ></TBODY ></TABLE ></DIV ></DIV ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >Índice</B ></DT ><DT ><A HREF="function.xmlreader-close.html" >XMLReader::close</A > -- Close the XMLReader input</DT ><DT ><A HREF="function.xmlreader-expand.html" >XMLReader::expand</A > -- Returns a copy of the current node as a DOM object</DT ><DT ><A HREF="function.xmlreader-getattribute.html" >XMLReader::getAttribute</A > -- Get the value of a named attribute</DT ><DT ><A HREF="function.xmlreader-getattributeno.html" >XMLReader::getAttributeNo</A > -- Get the value of an attribute by index</DT ><DT ><A HREF="function.xmlreader-getattributens.html" >XMLReader::getAttributeNs</A > -- Get the value of an attribute by localname and URI</DT ><DT ><A HREF="function.xmlreader-getparserproperty.html" >XMLReader::getParserProperty</A > -- Indicates if specified property has been set </DT ><DT ><A HREF="function.xmlreader-isvalid.html" >XMLReader::isValid</A > -- Indicates if the parsed document is valid</DT ><DT ><A HREF="function.xmlreader-lookupnamespace.html" >XMLReader::lookupNamespace</A > -- Lookup namespace for a prefix</DT ><DT ><A HREF="function.xmlreader-movetoattribute.html" >XMLReader::moveToAttribute</A > -- Move cursor to a named attribute</DT ><DT ><A HREF="function.xmlreader-movetoattributeno.html" >XMLReader::moveToAttributeNo</A > -- Move cursor to an attribute by index</DT ><DT ><A HREF="function.xmlreader-movetoattributens.html" >XMLReader::moveToAttributeNs</A > -- Move cursor to a named attribute</DT ><DT ><A HREF="function.xmlreader-movetoelement.html" >XMLReader::moveToElement</A > -- Position cursor on the parent Element of current Attribute</DT ><DT ><A HREF="function.xmlreader-movetofirstattribute.html" >XMLReader::moveToFirstAttribute</A > -- Position cursor on the first Attribute</DT ><DT ><A HREF="function.xmlreader-movetonextattribute.html" >XMLReader::moveToNextAttribute</A > -- Position cursor on the next Attribute</DT ><DT ><A HREF="function.xmlreader-next.html" >XMLReader::next</A > -- Move cursor to next node skipping all subtrees</DT ><DT ><A HREF="function.xmlreader-open.html" >XMLReader::open</A > -- Set the URI containing the XML to parse</DT ><DT ><A HREF="function.xmlreader-read.html" >XMLReader::read</A > -- Move to next node in document</DT ><DT ><A HREF="function.xmlreader-setparserproperty.html" >XMLReader::setParserProperty</A > -- Set or Unset parser options</DT ><DT ><A HREF="function.xmlreader-setrelaxngschema.html" >XMLReader::setRelaxNGSchema</A > -- Set the filename or URI for a RelaxNG Schema</DT ><DT ><A HREF="function.xmlreader-setrelaxngschemasource.html" >XMLReader::setRelaxNGSchemaSource</A > -- Set the data containing a RelaxNG Schema</DT ><DT ><A HREF="function.xmlreader-xml.html" >XMLReader::XML</A > -- Set the data containing the XML to parse</DT ></DL ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.xmlrpc-set-type.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Principal</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.xmlreader-close.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >xmlrpc_set_type</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="funcref.html" ACCESSKEY="U" >Acima</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >XMLReader::close</TD ></TR ></TABLE ></DIV ></BODY ></HTML >