Está en la página 1de 8

REPUBLICA BOLIVARIANA DE VENEZUELA

MINISTERIO DEL PODER POPULAR PARA LA DEFENSA


UNIVERSIDAD NACIONAL EXPERIMENTAL DE LA FUERZA ARMADA
NUCLEO CHUAO – CARACAS
INGENIERIA EN SISTEMAS
LENGUAJE DE PROGRAMACION II
5TO SEMESTRE D01

ARBOL DOM

Profesor: Alumno:

Ing. Jhony Grillet Vicencio Penott


C.I 20781042

Caracas, 16 de marzo del 2017.


Arbol DOM.

DOM o Document Object Model es un conjunto de utilidades específicamente


diseñadas para manipular documentos XML. Por extensión, DOM también se
puede utilizar para manipular documentos XHTML y HTML. Técnicamente, DOM
es una API de funciones que se pueden utilizar para manipular las páginas
XHTML de forma rápida y eficiente.

Antes de poder utilizar sus funciones, DOM transforma internamente el archivo


XML original en una estructura más fácil de manejar formada por una jerarquía
de nodos. De esta forma, DOM transforma el código XML en una serie de nodos
interconectados en forma de árbol.

El árbol generado no sólo representa los contenidos del archivo original


(mediante los nodos del árbol) sino que también representa sus relaciones
(mediante las ramas del árbol que conectan los nodos).

Aunque en ocasiones DOM se asocia con la programación web y con JavaScript,


la API de DOM es independiente de cualquier lenguaje de programación. De
hecho, DOM está disponible en la mayoría de lenguajes de programación
comúnmente empleados.

Si se considera la siguiente página HTML sencilla:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Página sencilla</title>

</head>

<body>
<p>Esta página es <strong>muy sencilla</strong></p>

</body>

</html>

Antes de poder utilizar las funciones de DOM, los navegadores convierten


automáticamente la página HTML anterior en la siguiente estructura de árbol de
nodos:

Representación en forma de árbol de la página HTML de ejemplo

La ventaja de emplear DOM es que permite a los programadores disponer de un


control muy preciso sobre la estructura del documento HTML o XML que están
manipulando. Las funciones que proporciona DOM permiten añadir, eliminar,
modificar y reemplazar cualquier nodo de cualquier documento de forma sencilla.

La primera especificación de DOM DOM Level 1) se definió en 1998 y permitió


homogeneizar la implementación del DHTML o HTML dinámico en los diferentes
navegadores, ya que permitía modificar el contenido de las páginas web sin
necesidad de recargar la página entera.
Los documentos XML y HTML tratados por DOM se convierten en una jerarquía
de nodos. Los nodos que representan los documentos pueden ser de diferentes
tipos. A continuación se detallan los tipos más importantes:

Document: es el nodo raíz de todos los documentos HTML y XML. Todos los
demás nodos derivan de él.

DocumentType: es el nodo que contiene la representación del DTD empleado en


la página (indicado mediante el DOCTYPE).

Element: representa el contenido definido por un par de etiquetas de apertura y


cierre (<etiqueta>...</etiqueta>) o de una etiqueta abreviada que se abre y se
cierra a la vez (<etiqueta/>). Es el único nodo que puede tener tanto nodos hijos
como atributos.

Su representación como árbol de nodos DOM es la


siguiente:

El nodo raíz siempre es el nodo de tipo Document, del que derivan todos los
demás nodos del documento. Este nodo es común para todas las páginas HTML
y todos los documentos XML. A continuación se incluye la etiqueta
<clientes>...</clientes>. Como se trata de una etiqueta, DOM la transforma en un
nodo de tipo Element. Además, como la etiqueta encierra a todos los demás
elementos de la página, el nodo Clientes de tipo Element deriva directamente de
Document y todos los demás nodos del documento derivan de ese nodo.

Document Object Properties and Methods

The following properties and methods can be used on HTML documents:

Property / Method Description

document.activeElement Returns the currently focused element in the


document

document.addEventListener() Attaches an event handler to the document

document.adoptNode() Adopts a node from another document

document.anchors Returns a collection of all <a> elements in the


document that have a name attribute

document.applets Returns a collection of all <applet> elements in


the document

document.baseURI Returns the absolute base URI of a document

document.body Sets or returns the document's body (the


<body> element)

document.close() Closes the output stream previously opened with


document.open()

document.cookie Returns all name/value pairs of cookies in the


document

document.charset Deprecated. Usedocument.characterSet instead.


Returns the character encoding for the
document

document.characterSet Returns the character encoding for the


document
document.createAttribute() Creates an attribute node

document.createComment() Creates a Comment node with the specified text

document.createDocumentFragment() Creates an empty DocumentFragment node

document.createElement() Creates an Element node

document.createTextNode() Creates a Text node

document.doctype Returns the Document Type Declaration


associated with the document

document.documentElement Returns the Document Element of the document


(the <html> element)

document.documentMode Returns the mode used by the browser to render


the document

document.documentURI Sets or returns the location of the document

document.domain Returns the domain name of the server that


loaded the document

document.domConfig Obsolete. Returns the DOM configuration of the


document

document.embeds Returns a collection of all <embed> elements


the document

document.forms Returns a collection of all <form> elements in


the document

document.getElementById() Returns the element that has the ID attribute


with the specified value

document.getElementsByClassName() Returns a NodeList containing all elements with


the specified class name
document.getElementsByName() Returns a NodeList containing all elements with
a specified name

document.getElementsByTagName() Returns a NodeList containing all elements with


the specified tag name

document.hasFocus() Returns a Boolean value indicating whether the


document has focus

document.head Returns the <head> element of the document

document.images Returns a collection of all <img> elements in the


document

document.implementation Returns the DOMImplementation object that


handles this document

document.importNode() Imports a node from another document

document.inputEncoding Returns the encoding, character set, used for


the document

document.lastModified Returns the date and time the document was


last modified

document.links Returns a collection of all <a> and <area>


elements in the document that have a href
attribute

document.normalize() Removes empty Text nodes, and joins adjacent


nodes

document.normalizeDocument() Removes empty Text nodes, and joins adjacent


nodes

document.open() Opens an HTML output stream to collect output


from document.write()

document.querySelector() Returns the first element that matches a


specified CSS selector(s) in the document

document.querySelectorAll() Returns a static NodeList containing all elements


that matches a specified CSS selector(s) in the
document

document.readyState Returns the (loading) status of the document

document.referrer Returns the URL of the document that loaded


the current document

document.removeEventListener() Removes an event handler from the document


(that has been attached with
the addEventListener() method)

document.renameNode() Renames the specified node

document.scripts Returns a collection of <script> elements in the


document

document.strictErrorChecking Sets or returns whether error-checking is


enforced or not

document.title Sets or returns the title of the document

document.URL Returns the full URL of the HTML document

document.write() Writes HTML expressions or JavaScript code to


a document

document.writeln() Same as write(), but adds a newline character


after each statement

También podría gustarte