Esercitazione XML

XML CASA Introduzione XML XML Come usare Albero XML Sintassi XML Elementi XML Attributi XML Spazi dei nomi XML Visualizzazione XML Richiesta HTTP XML Analizzatore XML XML DOM XPath XML XML XSLT XQuery XML XML XLink Validatore XML DTD XML Schema XML Server XML Esempi XML Quiz XML Certificato XML

XML AJAX

Introduzione AJAX AJAX XMLHttp Richiesta AJAX Risposta dell'AJAX File XML AJAX AJAX PHP AJAX ASP Database AJAX Applicazioni AJAX Esempi AJAX

XML DOM

DOM Introduzione Nodi DOM Accesso DOM Informazioni sul nodo DOM Elenco dei nodi DOM DOM attraversando Navigazione DOM DOM Ottieni valori Nodi di modifica DOM DOM Rimuovere i nodi DOM Sostituisci nodi DOM Crea nodi DOM Aggiungi nodi Clonazione dei nodi DOM Esempi DOM

Esercitazione XPath

Introduzione a XPath Nodi XPath Sintassi XPath Assi XPath Operatori XPath Esempi di XPath

Esercitazione XSLT

Introduzione a XSLT Lingue XSL Trasformazione XSLT XSLT <modello> XSLT <valore-di> XSLT <per-ciascuno> XSLT <ordina> XSLT <se> XSLT <scegli> Applicare XSLT XSLT sul Cliente XSLT sul server XSLT Modifica XML Esempi XSLT

Esercitazione XQuery

Introduzione a XQuery Esempio XQuery XQuery FLWOR XQuery HTML Termini di XQuery Sintassi XQuery Aggiungi XQuery XQuery Seleziona Funzioni XQuery

DTD XML

Introduzione alla DTD Blocchi di costruzione DTD Elementi DTD Attributi DTD Elementi DTD vs Attr Entità DTD Esempi di DTD

Schema XSD

Introduzione all'XSD XSD Come fare per XSD <schema> Elementi XSD Attributi XSD Restrizioni XSD

Complesso XSD

Elementi XSD XSD vuoto Solo elementi XSD Solo testo XSD XSD misto Indicatori XSD XSD <qualsiasi> XSD <qualsiasi attributo> Sostituzione XSD Esempio XSD

Dati XSD

Stringa XSD Data XSD Numerico XSD XSD Varie Riferimento XSD

Servizi Web

Servizi XML XML WSDL SAPONE XML XML RDF RSS XML

Riferimenti

Tipi di nodi DOM Nodo DOM Elenco nodi DOM DOM NamedNodeMap Documento DOM Elemento DOM Attributo DOM Testo DOM DOM CDATA Commento DOM DOM XMLHttpRichiesta Analizzatore DOM Elementi XSLT Funzioni XSLT/XPath

XML DOM - L' oggetto elemento


L'oggetto Elemento

L'oggetto Element rappresenta un elemento in un documento XML. Gli elementi possono contenere attributi, altri elementi o testo. Se un elemento contiene testo, il testo viene rappresentato in un nodo di testo.

IMPORTANTE! Il testo è sempre memorizzato nei nodi di testo. Un errore comune nell'elaborazione DOM è passare a un nodo elemento e aspettarsi che contenga il testo. Tuttavia, anche il nodo dell'elemento più semplice ha un nodo di testo sotto di esso. Ad esempio, in <anno>2005</anno>, c'è un nodo elemento (anno) e un nodo di testo sotto di esso, che contiene il testo (2005).

Poiché l'oggetto Element è anche un Node, eredita le proprietà ei metodi dell'oggetto Node.

Proprietà dell'oggetto elemento

Property Description
attributes Returns a NamedNodeMap of attributes for the element
baseURI Returns the absolute base URI of the element
childNodes Returns a NodeList of child nodes for the element
firstChild Returns the first child of the element
lastChild Returns the last child of the element
localName Returns the local part of the name of the element
namespaceURI Returns the namespace URI of the element
nextSibling Returns the node immediately following the element
nodeName Returns the name of the node, depending on its type
nodeType Returns the type of the node
ownerDocument Returns the root element (document object) for an element
parentNode Returns the parent node of the element
prefix Sets or returns the namespace prefix of the element
previousSibling Returns the node immediately before the element
schemaTypeInfo Returns the type information associated with the element
tagName Returns the name of the element
textContent Sets or returns the text content of the element and its descendants


Metodi dell'oggetto elemento

Method Description
appendChild() Adds a new child node to the end of the list of children of the node
cloneNode() Clones a node
compareDocumentPosition() Compares the document position of two nodes
getAttribute() Returns the value of an attribute
getAttributeNS() Returns the value of an attribute (with a namespace)
getAttributeNode() Returns an attribute node as an Attribute object
getAttributeNodeNS() Returns an attribute node (with a namespace) as an Attribute object
getElementsByTagName() Returns a NodeList of matching element nodes, and their children
getElementsByTagNameNS() Returns a NodeList of matching element nodes (with a namespace), and their children
getFeature(feature,version) Returns a DOM object which implements the specialized APIs of the specified feature and version
getUserData(key) Returns the object associated to a key on a this node. The object must first have been set to this node by calling setUserData with the same key
hasAttribute() Returns whether an element has any attributes matching a specified name
hasAttributeNS() Returns whether an element has any attributes matching a specified name and namespace
hasAttributes() Returns whether the element has any attributes
hasChildNodes() Returns whether the element has any child nodes
insertBefore() Inserts a new child node before an existing child node
isDefaultNamespace(URI) Returns whether the specified namespaceURI is the default
isEqualNode() Checks if two nodes are equal
lookupNamespaceURI() Returns the namespace URI matching a specified prefix
lookupPrefix() Returns the prefix matching a specified namespace URI
normalize() Puts all text nodes underneath this element (including attributes) into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes
removeAttribute() Removes a specified attribute
removeAttributeNS() Removes a specified attribute (with a namespace)
removeAttributeNode() Removes a specified attribute node
removeChild() Removes a child node
replaceChild() Replaces a child node
setUserData(key,data,handler) Associates an object to a key on the element
setAttribute() Adds a new attribute
setAttributeNS() Adds a new attribute (with a namespace)
setAttributeNode() Adds a new attribute node
setAttributeNodeNS(attrnode) Adds a new attribute node (with a namespace)
setIdAttribute(name,isId) If the isId property of the Attribute object is true, this method declares the specified attribute to be a user-determined ID attribute
setIdAttributeNS(uri,name,isId) If the isId property of the Attribute object is true, this method declares the specified attribute (with a namespace) to be a user-determined ID attribute
setIdAttributeNode(idAttr,isId) If the isId property of the Attribute object is true, this method declares the specified attribute to be a user-determined ID attribute