Diferencia entre revisiones de «Gambas/Manipular documentos XML»

Contenido eliminado Contenido añadido
Sin resumen de edición
Línea 5:
== '''Estructura básica de un documento XML''' ==
 
Todos los documentos XML inician con
No borrar se esta traduciendo al español!!!
<?xml version=”1.0” encoding=”UTF-16”?>
 
lo que indica que el resto del documento contiene datos en formato XML, especifica que versión esta siendo usada y la codificación Unicode de caracteres que contiene.
All XML documents start with <?xml version=”1.0” encoding=”UTF-16”?> which indicates that the rest of the document contain data in XML format, specify what version is being used and the Unicode character encoding.
OnEn versionla versión 1.0 youpuedes canomitir skipla to include thedeclaracion XML declaration, butpero forpara versionla versión 1.1 it ises mandatorymandatorio.
La declaración XML es seguida de un elemento 'raíz' que puede contener cualquier numero de subelementos entre sus etiqueta de inicio y final. Los elementos pueden contener atributos, y los nombres de atributo solo pueden aparecer solo una vez en un elemento. Los elementos deben estar adecuadamente anidados, no deben traslaparse, y por lo tanto deben ir cerrandose en el orden opuesto a como fueron abiertos. Los comentarios inician con un <!-- y terminana con -->. Con esto en mente, echale un vistazo al siguiente ''bien formado'' documento XML.
The XML declaration is followed by a ‘root’ element that can contain any number of sub-elements between their start-tag and end-tag, elements can contain attributes, and attribute names may appear only once in any single element. Elements must be properly nested, may never overlap, and so must be closed in the order opposite to which they were opened. XML comments start with <!-- and end with -->. With this in mind, take a look of the following small well-formed XML document.
<?xml version=”1.1” encoding=”UTF-16” ?>
<!-- TheLa previouslinea lineanterior ises thela XMLdeclaracion declarationXML -->
<!-- ThisEsta linelinea isy ala commentanterior son comentarios -->
<rootraiz>
<nombre_de_elemento nombre_de_atributo=”valor_del_atributo”>
<element_name attribute_name=”attribute_value”>
ElementContenido Contentdel elemento
</element_namenombre_de_elemento>
</rootraiz>
 
As you can see, the document is separated in different lines and there are some indentation to indicate the different levels of nesting, however this is not necessary the whole thing can be in just one text line. It is formatted in this way to help you understand the document. You’ll find this format useful when you need to read or edit a XML document on a text editor.
Como puedes ver, el documento esta separado en diferentes lineas y hay alguna identacion para indicar los diferentes niveles de anidacion, sin embargo esto no es necesario, todo el documento puede ir en una sola linea de texto. Esta formateado de esta manera para ayudarte a entender el documento. Encontraras muy util este manera de formatear los documentos XML cuando necesites leer o editar un documento XML en un editor de textos plano.
 
== '''Escribir XML''' ==