jmm-list-gn <jmm-> writes:
>Creating a XML query packet, however, seems to require having the element
>tags in the program as strings, and the wrapping them around the data as
>required. That is, an automated form of handwriting the XML file.
> Is this normally how it is done?
One can do so, or one might create a document model in memory
(a "DOM") and use a library to write it, or one might use a
library for writing XML.
Writing XML is much simplier than reading XML, because the
author of an XML document can chose what to write, while a
parser must be able to cope at any time with everything that
is possible in XML, actually even with everything that is
not possible, because the parser should also emit nice
error reports in such a case.
What is needed most often, when writing XML, is a subroutine
to replace special characters occuring in text (such as "<")
by a representation (such as "<"). When it gets the job
done, there is nothing wrong with just a "PRINT '<EXAMPLE>';"
to start an element. When certain patterns of such PRINT-
statements repeat in source code, one will start to catch them
as subroutines.
|