Creating XML data files

J

jmm-list-gn

Hello,
I am new to XML. One of the aspects in studying how XML documents are
manipulated is the assumption that XML data files spring spontaneously
into existence. Are all XML data files really handwritten?
I am working on a program that queries a package carrier's web service
about shipping rates. They have provided a number of XML schema (.xsd).
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?
Is there some way to use the schema files to get the appropriate tags
rather than have them written into the program?
 
S

Stefan Ram

jmm-list-gn said:
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.
 
E

Ed Day

jmm-list-gn said:
Hello,
I am new to XML. One of the aspects in studying how XML documents are
manipulated is the assumption that XML data files spring spontaneously
into existence. Are all XML data files really handwritten?
I am working on a program that queries a package carrier's web service
about shipping rates. They have provided a number of XML schema (.xsd).
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?
Is there some way to use the schema files to get the appropriate tags
rather than have them written into the program?

You might want to look into XML Data Binding applications. They can
generate code from a given XSD specification to serialize/deserialize
program data to and from XML. A Google search of "XML Data Binding"
will provide more information on these tools.

Regards,

Ed Day
Objective Systems, Inc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top