Re: reading XML string and writing it to a SQL database
- From: "Larry" <lkillen@xxxxxxxxxxx>
- Date: Tue, 27 Jun 2006 21:34:13 -0400
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>
.
- References:
- Prev by Date: reading XML string and writing it to a SQL database
- Next by Date: Re: reading XML string and writing it to a SQL database
- Previous by thread: reading XML string and writing it to a SQL database
- Next by thread: Re: reading XML string and writing it to a SQL database
- Index(es):
Relevant Pages
|