TrabalhosGratuitos.com - Trabalhos, Monografias, Artigos, Exames, Resumos de livros, Dissertações
Pesquisar

Erros em documentos XML

Seminário: Erros em documentos XML. Pesquise 860.000+ trabalhos acadêmicos

Por:   •  29/7/2014  •  Seminário  •  239 Palavras (1 Páginas)  •  220 Visualizações

Errors in XML documents will stop your XML program.

The W3C XML specification states that a program should not continue to process an XML document if it finds an error. The reason is that XML software should be easy to write, and that all XML documents should be compatible.

With HTML it was possible to create documents with "errors" (like dropping end tags). One of the main reasons that HTML browsers are so big and incompatible, is that they have their own ways to figure out what a document should look like when they encounter an HTML error.

With XML this should not be possible.

xmlDoc=loadXMLDoc("books.xml");

x=xmlDoc.documentElement;

//create a book element, title element and a text node

newNode=xmlDoc.createElement("book");

newTitle=xmlDoc.createElement("title");

newText=xmlDoc.createTextNode("A Notebook");

//add the text node to the title node,

newTitle.appendChild(newText);

//add the title node to the book node

newNode.appendChild(newTitle);

y=xmlDoc.getElementsByTagName("book")[0]

//replace the first book node with the new node

x.replaceChild(newNode,y);

xmlDoc=loadXMLDoc("books.xml");

x=xmlDoc.documentElement;

//create a book element, title element and a text node

newNode=xmlDoc.createElement("book");

newTitle=xmlDoc.createElement("title");

newText=xmlDoc.createTextNode("A Notebook");

//add the text node to the title node,

newTitle.appendChild(newText);

//add the title node to the book node

newNode.appendChild(newTitle);

y=xmlDoc.getElementsByTagName("book")[0]

//replace the first book node with the new node

x.replaceChild(newNode,y);

xmlDoc=loadXMLDoc("books.xml");

x=xmlDoc.documentElement;

//create a book element, title element and a text node

newNode=xmlDoc.createElement("book");

newTitle=xmlDoc.createElement("title");

newText=xmlDoc.createTextNode("A Notebook");

//add the text node to the title node,

newTitle.appendChild(newText);

...

Disponível apenas no TrabalhosGratuitos.com