Re: reading XML string and writing it to a SQL database



Let me re-create the data packet. Below is the content of the stream
(Buffer : String).

I send a Telnet "GetData" and all the weight records are returned in the
format below.

My goal is to parse the data packet and write the data to a MS/SQL database.
Since the structure was designed from the database table, the Data packet
should always map.

Delphi 2006 provides all kinds of tools to accomplish the task at hand. I
don't see any reason to create a DOM. I simply want to get the data from an
XML stream to a SQL table in a safe simple fashion.

What is the simplest and most efficent means to save the records below to a
SQL table.

TIA

Larry
This is not a cross-post. I asked a similar question in another group but
got no meaningful response. I am working with the output of a digital
scale. I retrieve the data from the scale via telnet as a text string.
The data is formatted with XML tags to denote the data attributes and
delimit each record. Mutiple records are normally in a single stream.
The records are very simple consisting of only 6 or 8 fields.

Neither I nor the embedded programmer are very verse in XML which accounts
for why I am asking for assistance.
The structure of the string lies below.


<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<DATAPACKET Version="2.0">
<METADATA>
<FIELDS>
<FIELD attrname="TXID" fieldtype="i2" />
<FIELD attrname="GroupID" fieldtype="i2" />
<FIELD attrname="ScaleID" fieldtype="i2" />
<FIELD attrname="LineID" fieldtype="i2" />
<FIELD attrname="StationID" fieldtype="i2" />
<FIELD attrname="Weight" fieldtype="fixed" DECIMALS="15"
WIDTH="18" />
<FIELD attrname="DateWeighed" fieldtype="dateTime" />
</FIELDS>
<PARAMS />
</METADATA>
<ROWDATA>
<ROW TXID="3" GroupID="10" ScaleID="1" LineID="1" StationID="1"
Weight="23.344600000000000"
DateWeighed="20060627T16:19:00000" />
<ROW TXID="3" GroupID="7" ScaleID="1" LineID="1" StationID="7"
Weight="23.581200000000000" DateWeighed="20060627T16:24:00000" />
<ROW TXID="3" GroupID="7" ScaleID="1" LineID="1" StationID="7"
Weight="24.581200000000000" DateWeighed="20060627T16:25:18150" />
<ROW TXID="4" GroupID="7" ScaleID="1" LineID="1" StationID="7"
Weight="24.580200000000000" DateWeighed="20060627T16:25:30350" />
</ROWDATA>
</DATAPACKET>





.



Relevant Pages

  • Re: Reading 8 bit chars off a stream
    ... You might want to consider a MemoryStream instead of a Listto ... stream internally, and if the device isn't going to offer up anything past ... data packet are null terminted. ... Encoding to get the string. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Question about design, defmacro, macrolet, and &environment
    ... "Expects to find the literal string on the stream." ... (defun send (string &optional stream) ... (declaim (inline make-adjustable-string)) ...
    (comp.lang.lisp)
  • Re: Strange problem when not in debugger
    ... private string huidigWeb; ... int buffLength = 2048; ... // Opens a file stream to read the file to be uploaded ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: ReplacerStream
    ... string, do a replace on that string and create a stream again to be ... If those are problems, and you are looking just for a single string, it seems to me that you could just read the stream one character at a time, checking to see if it matches the current character in your search string. ...
    (microsoft.public.dotnet.framework)
  • Re: Strange problem when not in debugger
    ... private string huidigWeb; ... int buffLength = 2048; ... // Opens a file stream to read the file to be uploaded ...
    (microsoft.public.dotnet.languages.csharp)