Tutorial de XML

XML INÍCIO Introdução ao XML XML Como usar Árvore XML Sintaxe XML Elementos XML Atributos XML Namespaces XML Exibição XML XML HttpRequest Analisador de XML XML DOM XML XPath XML XSLT XML XQuery XML XLink Validador de XML XML DTD Esquema XML Servidor XML Exemplos XML Teste de XML Certificado XML

XML AJAX

Introdução AJAX AJAX XML Http Solicitação AJAX Resposta AJAX Arquivo XML AJAX PHP AJAX ASP AJAX Banco de dados AJAX Aplicativos AJAX Exemplos AJAX

XML DOM

Introdução ao DOM Nós DOM Acesso ao DOM Informações do nó DOM Lista de nós DOM Travessia do DOM Navegação DOM Valores de obtenção do DOM Nós de alteração do DOM Remoção de nós do DOM Substituir nós DOM DOM Criar nós DOM Adicionar nós Nós clones DOM Exemplos de DOM

Tutorial XPath

Introdução ao XPath Nós XPath Sintaxe XPath Eixos XPath Operadores XPath Exemplos de XPath

Tutorial XSLT

Introdução ao XSLT Idiomas XSL Transformação XSLT XSLT <modelo> XSLT <valor-de> XSLT <para-cada> XSLT <classificar> XSLT <if> XSLT <escolha> Aplicar XSLT XSLT no cliente XSLT no servidor XSLT Editar XML Exemplos de XSLT

Tutorial XQuery

Introdução ao XQuery Exemplo de XQuery XQuery FLWOR XQuery HTML Termos de XQuery Sintaxe XQuery Adicionar XQuery Seleção de XQuery Funções XQuery

XML DTD

Introdução DTD Blocos de construção de DTD Elementos DTD Atributos DTD Elementos DTD vs Attr Entidades DTD Exemplos de DTD

Esquema XSD

Introdução ao XSD XSD Como fazer XSD <esquema> Elementos XSD Atributos XSD Restrições XSD

Complexo XSD

Elementos XSD XSD vazio Apenas elementos XSD Somente texto XSD XSD Misto Indicadores XSD XSD <qualquer> XSD <qualquer atributo> Substituição XSD Exemplo de XSD

Dados XSD

Cadeia XSD Data XSD XSD Numérico XSD Misc Referência XSD

Serviços da Web

Serviços XML XML WSDL XML SOAP XML RDF XML RSS

Referências

Tipos de nós DOM Nó DOM Lista de nós DOM DOM NamedNodeMap Documento DOM Elemento DOM Atributo DOM Texto DOM DOM CDATA Comentário DOM DOM XMLHttpRequest Analisador de DOM Elementos XSLT Funções XSLT/XPath

XML DOM - O Objeto Documento


O objeto Document representa todo o documento XML.


O objeto de documento XML

O objeto Document é a raiz de uma árvore de documentos XML e nos dá o acesso primário aos dados do documento.

Como nós de elemento, nós de texto, comentários, instruções de processamento, etc. não podem existir fora do documento, o objeto Document também contém métodos para criar esses objetos. Os objetos Node possuem uma propriedade ownerDocument que os associa ao Documento onde foram criados.

Propriedades do objeto de documento

Property Description
childNodes Returns a NodeList of child nodes for the document
doctype Returns the Document Type Declaration associated with the document
documentElement Returns the root node of the document
documentURI Sets or returns the location of the document
domConfig Returns the configuration used when normalizeDocument() is invoked
firstChild Returns the first child node of the document
implementation Returns the DOMImplementation object that handles this document
inputEncoding Returns the encoding used for the document (when parsing)
lastChild Returns the last child node of the document
nodeName Returns the name of a node (depending on its type)
nodeType Returns the node type of a node
nodeValue Sets or returns the value of a node (depending on its type)
xmlEncoding Returns the XML encoding of the document
xmlStandalone Sets or returns whether the document is standalone
xmlVersion Sets or returns the XML version of the document

Métodos de objeto de documento

Method Description
adoptNode(sourcenode) Adopts a node from another document to this document, and returns the adopted node
createAttribute(name) Creates an attribute node with the specified name, and returns the new Attr object
createAttributeNS(uri,name) Creates an attribute node with the specified name and namespace, and returns the new Attr object
createCDATASection() Creates a CDATA section node
createComment() Creates a comment node
createDocumentFragment() Creates an empty DocumentFragment object, and returns it
createElement() Creates an element node
createElementNS() Creates an element node with a specified namespace
createEntityReference(name) Creates an EntityReference object, and returns it
createProcessingInstruction(target,data) Creates a ProcessingInstruction object, and returns it
createTextNode() Creates a text node
getElementById(id) Returns the element that has an ID attribute with the given value. If no such element exists, it returns null
getElementsByTagName() Returns a NodeList of all elements with a specified name
getElementsByTagNameNS() Returns a NodeList of all elements with a specified name and namespace
importNode(nodetoimport,deep) Imports a node from another document to this document. This method creates a new copy of the source node. If the deep parameter is set to true, it imports all children of the specified node. If set to false, it imports only the node itself. This method returns the imported node
normalizeDocument()  
renameNode() Renames an element or attribute node


Propriedades do objeto DocumentType

Cada documento tem um atributo DOCTYPE cujo valor é null ou um objeto DocumentType.

O objeto DocumentType fornece uma interface para as entidades definidas para um documento XML.

Property Description
name Returns the name of the DTD
publicId Returns the public identifier of the DTD
systemId Returns the system identifier of the external DTD

Métodos de Objeto de Implementação de Documentos

O objeto DOMImplementation executa operações independentes de qualquer instância específica do modelo de objeto do documento.

Method Description
createDocument(nsURI, name, doctype) Creates a new DOM Document object of the specified doctype
createDocumentType(name, pubId, systemId) Creates an empty DocumentType node
getFeature(feature, version) Returns an object which implements the APIs of the specified feature and version, if the is any
hasFeature(feature, version) Checks whether the DOM implementation implements a specific feature and version

Propriedades do objeto de instrução de processamento

O objeto ProcessingInstruction representa uma instrução de processamento.

Uma instrução de processamento é usada como forma de manter informações específicas do processador no texto do documento XML.

Property Description
data Sets or returns the content of this processing instruction
target Returns the target of this processing instruction