Create an XML file with ASP
One of the most interesting languages \u200b\u200bto synchronize data from different sources, for example, used to synchronize data from local to remote, is XML.
The first line of a basic XML file indicates the version and encoding of the file and will be:
"\u0026lt;? Xml version =" 1.0 "encoding =" UTF-8 ""?>"
Then start
XML.
XML is very similar to HTML, is structured in a "tag". All XML tags must be closed, however.
The XML has a root tag, also called root node, which would contain within it all the child nodes.
Example:
\u0026lt;nodoprincipale>
\u0026lt;nodo> Content 1 \u0026lt;/ node>
\u0026lt;nodo> Content 2 \u0026lt;/ node>
\u0026lt;nodo> Content 3 \u0026lt;/ node>
\u0026lt;/ nodoprincipale>
Let's see how to create a file on our server, xml:
to create this file we will use an object "FileSystemObject"
\u0026lt;% Dim
OggFile, source, origin OggTextStream
= Server.MapPath ("/ public / file.xml") Set fso = CreateObject
("Scripting.FileSystemObject")
fso.CreateTextFile (source)
September OggFile fso.GetFile = (source)
Set OggTextStream = OggFile.OpenAsTextStream(2)
OggTextStream.WriteLine "<?xml version=""1.0"" encoding=""UTF-8""?>"
OggTextStream.WriteLine "<fotos>"
OggTextStream.WriteLine "<foto photo=''>Immagine 1</foto>"
OggTextStream.WriteLine "<foto photo=''>Immagine 2</foto>"
OggTextStream.WriteLine "<foto photo=''>Immagine 3</foto>"
OggTextStream.WriteLine "<foto photo=''>Immagine 4</foto>"
OggTextStream.WriteLine "\u0026lt;/ Photos>"
OggTextStream.close
response.write "Writing successful. \u0026lt;a Href="/public/file.xml"> View \u0026lt;/ a>"
%>
The proposed link at the end of creation, open the file you created.
0 comments:
Post a Comment