最佳实践 - XML处理?? [英] Best Practice - XML processing??

查看:68
本文介绍了最佳实践 - XML处理??的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿所有,


我有一个XML文档,我从一个集成

feed读入SQL Server数据库....


---------------- XML片段----------------

<?xml version =" 1.0" encoding =" us-ascii"?>

<! - 来自JDEdwards的产品数据 - >

< Root>

< Root RvcDate =" 2004-02-03" RcvTime =" 14.16.03.795135">

< Product>

< File> 1234A< / File>

<图书馆> XCOMM< /图书馆>

< ActionCode> A< / ActionCode>

< TransDate> 2004-02-03< / TransDate>

< TransTime> 14.18.39.337626< / TransTime>

< Details Name =" JBMCUS"值= QUOT; 1234567890" />

< Details Name =" JBALOT"值= QUOT; 1234" />

< Details Name =" JBSEQ2"值= QUOT; 00856" />

< Details Name =" JBLTP"值= QUOT; 123456.00" />

< Details Name =" JBADD1"值=" 1234 Garrity Way" />

< Details Name =" JBDL01"值= QUOT;" />

< Details Name =" JBRDJ"值= QUOT; 000000" />

< Details Name =" JBFD01"值= QUOT;" />

< Details Name =" JBUSD1"值= QUOT; 000000" />

< / Product>

< Product>

< File> 1234B< / File>

< Library> XCOMM< / Library>

< ActionCode> A< / ActionCode>

< TransDate> 2004-02-03< / TransDate>

< TransTime> 14.18.39.337923< / TransTime>

< Details Name =" JBMCUS"值= QUOT; 1234567890" />

< Details Name =" JBALOT"值= QUOT; 4567" />

< Details Name =" JBSEQ2"值= QUOT; 00856" />

< Details Name =" JBLTP"值= QUOT; 123456.00" />

< Details Name =" JBADD1"值=4567 Garrity Way />

< Details Name =" JBDL01"值= QUOT;" />

< Details Name =" JBRDJ"值= QUOT; 000000" />

< Details Name =" JBFD01"值= QUOT;" />

< Details Name =" JBUSD1"值= QUOT; 000000" />

< / Product>

< Product>

< File> 1234A< / File>

< Library> XCOMM< / Library>

< ActionCode> A< / ActionCode>

< TransDate> 2004-02-03< / TransDate>

< TransTime> 14.18.39.412541< / TransTime>

< Details Name =" JBMCUS"值= QUOT; 1234567890" />

< Details Name =" JBALOT"值= QUOT; 9876" />

< Details Name =" JBSEQ2"值= QUOT; 00856" />

< Details Name =" JBLTP"值= QUOT; 123456.00" />

< Details Name =" JBADD1"值=" 9876 Main St" />

< Details Name =" JBDL01"值= QUOT;" />

< Details Name =" JBRDJ"值= QUOT; 000000" />

< Details Name =" JBFD01"值= QUOT;" />

< Details Name =" JBUSD1"值= QUOT; 000000" />

< / Product>

< / Root>

< / Root>

----------------结束XML片段----------------


目前,我将XML加载到数据集中并在

数据集中的每个数据行上循环,并将每一行作为单个事务处理。我很好奇

知道是否有一个标准的方法来完成目标,如果

路径我选择了如果有效或是有更好的方法吗?


建议或任何形式的反馈将不胜感激。


TIA

-Rich

解决方案

Rich - 你的Xml doc有多大?

老实说我对SqlXml非常满意批量上传这个

类的工作 - 主要是因为它为你做了很多东西。它还支持交易,如果需要,它本身在交易时以批量方式运行。

上传。

你看过那个吗?如果你的文件不是很大,那可能有点过头了,但即使对于合理大小的文件我发现它比编写代码流要好得多。

。 br />

查看帖子从XML自动创建数据库模式

数据集来自Fed 2nd的更多信息。


史蒂文

创始人, http://venturetogether.com


" Rich Wallace" <关于** @ qwerty.com>写在消息

新闻:uJ ************* @ TK2MSFTNGP12.phx.gbl ...

嘿所有,
我有一个XML文档,我从
集成提要读入SQL Server数据库....

------------ ---- XML片段----------------
<?xml version =" 1.0" encoding =" us-ascii"?>
<! - 来自JDEdwards的产品数据 - >
< Root>
< Root RvcDate =" 2004-02 -03" RcvTime =" 14.16.03.795135">
< Product>
< File> 1234A< / File>
< Library> XCOMM< / Library>
< ; ActionCode> A< / ActionCode>
< TransDate> 2004-02-03< / TransDate>
< TransTime> 14.18.39.337626< / TransTime>
<详情名称= " JBMCUS"值= QUOT; 1234567890" />
< Details Name =" JBALOT"值= QUOT; 1234" />
< Details Name =" JBSEQ2"值= QUOT; 00856" />
< Details Name =" JBLTP"值= QUOT; 123456.00" />
< Details Name =" JBADD1"值=" 1234 Garrity Way" />
< Details Name =" JBDL01"值= QUOT;" />
< Details Name =" JBRDJ"值= QUOT; 000000" />
< Details Name =" JBFD01"值= QUOT;" />
< Details Name =" JBUSD1"值= QUOT; 000000" />
< / Product>
<产品>
<文件> 1234B< / File>
<图书馆> XCOMM< / Library>
< ActionCode> A< / ActionCode>
< TransDate> 2004-02-03< / TransDate>
< TransTime> 14.18.39.337923< / TransTime>
<详情名称= QUOT; JBMCUS"值= QUOT; 1234567890" />
< Details Name =" JBALOT"值= QUOT; 4567" />
< Details Name =" JBSEQ2"值= QUOT; 00856" />
< Details Name =" JBLTP"值= QUOT; 123456.00" />
< Details Name =" JBADD1"值=4567 Garrity Way />
< Details Name =" JBDL01"值= QUOT;" />
< Details Name =" JBRDJ"值= QUOT; 000000" />
< Details Name =" JBFD01"值= QUOT;" />
< Details Name =" JBUSD1"值= QUOT; 000000" />
< / Product>
< Product>
< File> 1234A< / File>
< Library> XCOMM< / Library>
< ActionCode> A< / ActionCode>
< TransDate> 2004-02-03< / TransDate>
< TransTime> 14.18.39.412541< / TransTime>
<详情名称= QUOT; JBMCUS"值= QUOT; 1234567890" />
< Details Name =" JBALOT"值= QUOT; 9876" />
< Details Name =" JBSEQ2"值= QUOT; 00856" />
< Details Name =" JBLTP"值= QUOT; 123456.00" />
< Details Name =" JBADD1"值=" 9876 Main St" />
< Details Name =" JBDL01"值= QUOT;" />
< Details Name =" JBRDJ"值= QUOT; 000000" />
< Details Name =" JBFD01"值= QUOT;" />
< Details Name =" JBUSD1"值= QUOT; 000000" />
< / Product>
< / Root>
< / Root>
----------------结束XML片段----------------

目前,我将XML加载到数据集中并在
数据集和进程中的每个数据行上循环每行作为单独的交易。我很想知道是否有一个标准的方法来完成目标,如果我选择的路径是否有效还是有更好的方法?

建议或任何形式的反馈将不胜感激。

TIA
-Rich



Hi Steven,

我接受的XML文档可以包含1< Product>中的任何内容。到了500.

不幸的是,我需要做的事情并不像进行批量加载那么简单,因为我需要执行几个业务规则和其他检查和平衡在

之前,数据被推送到SQL。我通过参数化存储过程将数据驱动到数据库中的方式是

所以我实际上并没有将XML数据推送到表中,而是从表中解析出数据XML。


我觉得使用数据集是非常快速和高效但我总是

质疑我的选择作为待机''必须有一个更好的方式!!!"


感谢您的投入。

-Rich


" Steven Livingstone" < S *********** @ nospam.btinternet.com>。在消息中写道

news:uT ************** @ TK2MSFTNGP12.phx.gbl ...

Rich - 有多大你得到Xml doc吗?
说实话我很满意SqlXml和Bulk Upload的东西,这是
这种工作 - 主要是因为它为你做了很多东西。如果需要,它还支持交易,当
批量上传时,它本身也会以交易方式运行。
你看过那个吗?如果您的文档太大,可能会有点过分,但即使对于合理大小的文档,我发现它比编写代码流要好得多b $ b $。

有看看帖子从XML
数据集自动创建数据库模式来自Fed 2nd的更多信息。

Steven
创始人, http:// venturetogether.com

Rich Wallace <关于** @ qwerty.com>在消息中写道
新闻:uJ ************* @ TK2MSFTNGP12.phx.gbl ...

嘿所有,
我有一个XML文档,我从


集成

feed读入SQL Server数据库....

---- ------------ XML片段----------------
<?xml version =" 1.0" encoding =" us-ascii"?>
<! - 来自JDEdwards的产品数据 - >
< Root>
< Root RvcDate =" 2004-02 -03" RcvTime =" 14.16.03.795135">
< Product>
< File> 1234A< / File>
< Library> XCOMM< / Library>
< ; ActionCode> A< / ActionCode>
< TransDate> 2004-02-03< / TransDate>
< TransTime> 14.18.39.337626< / TransTime>
<详情名称= " JBMCUS"值= QUOT; 1234567890" />
< Details Name =" JBALOT"值= QUOT; 1234" />
< Details Name =" JBSEQ2"值= QUOT; 00856" />
< Details Name =" JBLTP"值= QUOT; 123456.00" />
< Details Name =" JBADD1"值=" 1234 Garrity Way" />
< Details Name =" JBDL01"值= QUOT;" />
< Details Name =" JBRDJ"值= QUOT; 000000" />
< Details Name =" JBFD01"值= QUOT;" />
< Details Name =" JBUSD1"值= QUOT; 000000" />
< / Product>
<产品>
<文件> 1234B< / File>
<图书馆> XCOMM< / Library>
< ActionCode> A< / ActionCode>
< TransDate> 2004-02-03< / TransDate>
< TransTime> 14.18.39.337923< / TransTime>
<详情名称= QUOT; JBMCUS"值= QUOT; 1234567890" />
< Details Name =" JBALOT"值= QUOT; 4567" />
< Details Name =" JBSEQ2"值= QUOT; 00856" />
< Details Name =" JBLTP"值= QUOT; 123456.00" />
< Details Name =" JBADD1"值=4567 Garrity Way />
< Details Name =" JBDL01"值= QUOT;" />
< Details Name =" JBRDJ"值= QUOT; 000000" />
< Details Name =" JBFD01"值= QUOT;" />
< Details Name =" JBUSD1"值= QUOT; 000000" />
< / Product>
< Product>
< File> 1234A< / File>
< Library> XCOMM< / Library>
< ActionCode> A< / ActionCode>
< TransDate> 2004-02-03< / TransDate>
< TransTime> 14.18.39.412541< / TransTime>
<详情名称= QUOT; JBMCUS"值= QUOT; 1234567890" />
< Details Name =" JBALOT"值= QUOT; 9876" />
< Details Name =" JBSEQ2"值= QUOT; 00856" />
< Details Name =" JBLTP"值= QUOT; 123456.00" />
< Details Name =" JBADD1"值=" 9876 Main St" />
< Details Name =" JBDL01"值= QUOT;" />
< Details Name =" JBRDJ"值= QUOT; 000000" />
< Details Name =" JBFD01"值= QUOT;" />
< Details Name =" JBUSD1"值= QUOT; 000000" />
< / Product>
< / Root>
< / Root>
----------------结束XML片段----------------

目前,我将XML加载到数据集中并在
数据集和进程中的每个数据行上循环每行作为单独的交易。我很好奇
,知道是否有一个标准方法来完成目标,如果我选择了
路径,如果有效还是有更好的方法?

建议或任何形式的反馈将不胜感激。

TIA
-Rich




我们在一段时间的工作中遇到了类似的情况。

我们使用了以下解决方案。


1.接受文件为Xml。

2.使用XPath来处理我们的业务规则 - 使用多个XPath

。有时你不得不打电话给自定义课程,但不经常。

3.将我们的Xml转换为批量上传格式。

4.通过它。


3和4你可以很容易地成为SqlXml并从那里使用你的存储Prcos。

IMO将Xml直接推送到sql更容易 - 甚至通过SP',

而不是进步。


这里很酷的文章 http://sightkeys.com?181 此处
http://sightkeys.com?182

祝你选择的方法好运。


史蒂文

创始人, http://venturetogether.com

Rich Wallace <关于** @ qwerty.com>在消息中写道

新闻:Ov ************** @ TK2MSFTNGP09.phx.gbl ...

嗨史蒂文,

我接受的XML文档可以包含1< Product>中的任何位置。
500.不幸的是,我需要做的事情并不像进行批量加载那么简单,因为我必须执行多个业务规则和其他检查并在数据获得之前平衡
推到SQL。我将数据驱动到数据库
的方式是通过参数化存储过程,所以我实际上并没有将XML数据推送到表中,而是从XML中解析出数据。

我觉得使用数据集非常快速有效但是我总是质疑我的选择作为待机''必须有更好的方法!!!'

谢谢你你的意见。
-Rich

Steven Livingstone < S *********** @ nospam.btinternet.com>。写在
消息新闻:uT ************** @ TK2MSFTNGP12.phx.gbl ...

Rich - 你的Xml doc有多大?
说实话,我非常满意这个

工作的SqlXml和Bulk Upload的东西 - 主要是因为它为你做了很多东西。如果需要,它还支持事务,并且当


批量

上传时,它本身会以事务方式运行。
你看过那个吗?如果您的文档太大,可能会有点过分,但即使对于合理大小的文档,我发现它比编写流更好


代码。

查看帖子从XML
数据集自动创建数据库模式来自Fed 2nd的更多信息。

Steven
创始人, http:// venturetogether.com

Rich Wallace <关于** @ qwerty.com>在消息中写道
新闻:uJ ************* @ TK2MSFTNGP12.phx.gbl ...

嘿所有,
我有一个XML文档,我从


集成

feed读入SQL Server数据库....

---- ------------ XML片段----------------
<?xml version =" 1.0" encoding =" us-ascii"?>
<! - 来自JDEdwards的产品数据 - >
< Root>
< Root RvcDate =" 2004-02 -03" RcvTime =" 14.16.03.795135">
< Product>
< File> 1234A< / File>
< Library> XCOMM< / Library>
< ; ActionCode> A< / ActionCode>
< TransDate> 2004-02-03< / TransDate>
< TransTime> 14.18.39.337626< / TransTime>
<详情名称= " JBMCUS"值= QUOT; 1234567890" />
< Details Name =" JBALOT"值= QUOT; 1234" />
< Details Name =" JBSEQ2"值= QUOT; 00856" />
< Details Name =" JBLTP"值= QUOT; 123456.00" />
< Details Name =" JBADD1"值=" 1234 Garrity Way" />
< Details Name =" JBDL01"值= QUOT;" />
< Details Name =" JBRDJ"值= QUOT; 000000" />
< Details Name =" JBFD01"值= QUOT;" />
< Details Name =" JBUSD1"值= QUOT; 000000" />
< / Product>
<产品>
<文件> 1234B< / File>
<图书馆> XCOMM< / Library>
< ActionCode> A< / ActionCode>
< TransDate> 2004-02-03< / TransDate>
< TransTime> 14.18.39.337923< / TransTime>
<详情名称= QUOT; JBMCUS"值= QUOT; 1234567890" />
< Details Name =" JBALOT"值= QUOT; 4567" />
< Details Name =" JBSEQ2"值= QUOT; 00856" />
< Details Name =" JBLTP"值= QUOT; 123456.00" />
< Details Name =" JBADD1"值=4567 Garrity Way />
< Details Name =" JBDL01"值= QUOT;" />
< Details Name =" JBRDJ"值= QUOT; 000000" />
< Details Name =" JBFD01"值= QUOT;" />
< Details Name =" JBUSD1"值= QUOT; 000000" />
< / Product>
< Product>
< File> 1234A< / File>
< Library> XCOMM< / Library>
< ActionCode> A< / ActionCode>
< TransDate> 2004-02-03< / TransDate>
< TransTime> 14.18.39.412541< / TransTime>
<详情名称= QUOT; JBMCUS"值= QUOT; 1234567890" />
< Details Name =" JBALOT"值= QUOT; 9876" />
< Details Name =" JBSEQ2"值= QUOT; 00856" />
< Details Name =" JBLTP"值= QUOT; 123456.00" />
< Details Name =" JBADD1"值=" 9876 Main St" />
< Details Name =" JBDL01"值= QUOT;" />
< Details Name =" JBRDJ"值= QUOT; 000000" />
< Details Name =" JBFD01"值= QUOT;" />
< Details Name =" JBUSD1"值= QUOT; 000000" />
< / Product>
< / Root>
< / Root>
----------------结束XML片段----------------

目前,我将XML加载到数据集中并在
中的每个数据行上循环数据集和过程每行作为单独的交易。我很想知道

知道是否有一个'标准'方法来完成目标,如果



我选择的路径是否有效或有更好的方法吗?

建议或任何形式的反馈将不胜感激。

TIA
-Rich





Hey all,

I have an XML doc that I read into a SQL Server database from an integration
feed....

----------------XML snippet ----------------
<?xml version="1.0" encoding="us-ascii"?>
<!--Product data from JDEdwards-->
<Root>
<Root RvcDate="2004-02-03" RcvTime="14.16.03.795135">
<Product>
<File>1234A</File>
<Library>XCOMM</Library>
<ActionCode>A</ActionCode>
<TransDate>2004-02-03</TransDate>
<TransTime>14.18.39.337626</TransTime>
<Details Name="JBMCUS" Value="1234567890" />
<Details Name="JBALOT" Value="1234" />
<Details Name="JBSEQ2" Value="00856" />
<Details Name="JBLTP" Value="123456.00" />
<Details Name="JBADD1" Value="1234 Garrity Way" />
<Details Name="JBDL01" Value="" />
<Details Name="JBRDJ" Value="000000" />
<Details Name="JBFD01" Value="" />
<Details Name="JBUSD1" Value="000000" />
</Product>
<Product>
<File>1234B</File>
<Library>XCOMM</Library>
<ActionCode>A</ActionCode>
<TransDate>2004-02-03</TransDate>
<TransTime>14.18.39.337923</TransTime>
<Details Name="JBMCUS" Value="1234567890" />
<Details Name="JBALOT" Value="4567" />
<Details Name="JBSEQ2" Value="00856" />
<Details Name="JBLTP" Value="123456.00" />
<Details Name="JBADD1" Value="4567 Garrity Way" />
<Details Name="JBDL01" Value="" />
<Details Name="JBRDJ" Value="000000" />
<Details Name="JBFD01" Value="" />
<Details Name="JBUSD1" Value="000000" />
</Product>
<Product>
<File>1234A</File>
<Library>XCOMM</Library>
<ActionCode>A</ActionCode>
<TransDate>2004-02-03</TransDate>
<TransTime>14.18.39.412541</TransTime>
<Details Name="JBMCUS" Value="1234567890" />
<Details Name="JBALOT" Value="9876" />
<Details Name="JBSEQ2" Value="00856" />
<Details Name="JBLTP" Value="123456.00" />
<Details Name="JBADD1" Value="9876 Main St" />
<Details Name="JBDL01" Value="" />
<Details Name="JBRDJ" Value="000000" />
<Details Name="JBFD01" Value="" />
<Details Name="JBUSD1" Value="000000" />
</Product>
</Root>
</Root>
----------------End XML snippet ----------------

Currently, I load the XML into a dataset and loop on each datarow in the
dataset and process each row as an individual transaction. I''m curious to
know if there is a ''standard'' approach on completing the goal and if the
path I''ve selected if efficient or is there a better way?

Suggestions or any kind of feedback would be appreciated.

TIA
-Rich

解决方案

Rich - how big does you Xml doc get?
To be honest I was very happy with the SqlXml and Bulk Upload stuff for this
kind of work - mainly as it does a lot of the stuff for you. It also
supports transactions if required and itself runs transactionally when bulk
uploading.
Have you looked at that? It might be overkill if your document isn''t too
large, but even for reasonable sized documents i found it to be much better
than writing streams of code.

Have a look at the post "Automagically create database schema from XML
dataset" from Fed 2nd for more info.

Steven
Founder, http://venturetogether.com

"Rich Wallace" <as**@qwerty.com> wrote in message
news:uJ*************@TK2MSFTNGP12.phx.gbl...

Hey all,

I have an XML doc that I read into a SQL Server database from an integration feed....

----------------XML snippet ----------------
<?xml version="1.0" encoding="us-ascii"?>
<!--Product data from JDEdwards-->
<Root>
<Root RvcDate="2004-02-03" RcvTime="14.16.03.795135">
<Product>
<File>1234A</File>
<Library>XCOMM</Library>
<ActionCode>A</ActionCode>
<TransDate>2004-02-03</TransDate>
<TransTime>14.18.39.337626</TransTime>
<Details Name="JBMCUS" Value="1234567890" />
<Details Name="JBALOT" Value="1234" />
<Details Name="JBSEQ2" Value="00856" />
<Details Name="JBLTP" Value="123456.00" />
<Details Name="JBADD1" Value="1234 Garrity Way" />
<Details Name="JBDL01" Value="" />
<Details Name="JBRDJ" Value="000000" />
<Details Name="JBFD01" Value="" />
<Details Name="JBUSD1" Value="000000" />
</Product>
<Product>
<File>1234B</File>
<Library>XCOMM</Library>
<ActionCode>A</ActionCode>
<TransDate>2004-02-03</TransDate>
<TransTime>14.18.39.337923</TransTime>
<Details Name="JBMCUS" Value="1234567890" />
<Details Name="JBALOT" Value="4567" />
<Details Name="JBSEQ2" Value="00856" />
<Details Name="JBLTP" Value="123456.00" />
<Details Name="JBADD1" Value="4567 Garrity Way" />
<Details Name="JBDL01" Value="" />
<Details Name="JBRDJ" Value="000000" />
<Details Name="JBFD01" Value="" />
<Details Name="JBUSD1" Value="000000" />
</Product>
<Product>
<File>1234A</File>
<Library>XCOMM</Library>
<ActionCode>A</ActionCode>
<TransDate>2004-02-03</TransDate>
<TransTime>14.18.39.412541</TransTime>
<Details Name="JBMCUS" Value="1234567890" />
<Details Name="JBALOT" Value="9876" />
<Details Name="JBSEQ2" Value="00856" />
<Details Name="JBLTP" Value="123456.00" />
<Details Name="JBADD1" Value="9876 Main St" />
<Details Name="JBDL01" Value="" />
<Details Name="JBRDJ" Value="000000" />
<Details Name="JBFD01" Value="" />
<Details Name="JBUSD1" Value="000000" />
</Product>
</Root>
</Root>
----------------End XML snippet ----------------

Currently, I load the XML into a dataset and loop on each datarow in the
dataset and process each row as an individual transaction. I''m curious to
know if there is a ''standard'' approach on completing the goal and if the
path I''ve selected if efficient or is there a better way?

Suggestions or any kind of feedback would be appreciated.

TIA
-Rich



Hi Steven,

The XML document that I accept can contain anywhere from 1 <Product> to 500.
Unfortunately, what I need to do isn''t as simple as doing a bulk load as I
have to perform several business rules and other checks and balances before
the data gets pushed to SQL. The way I drive the data into the database is
via parameterized stored procedures so I don''t actually push XML data into
the table, rather parsed out data from the XML.

I feel that working with datasets are quite fast and efficient but I always
question my selection as the standby ''There has to be a better way!!!"

Thanks for your input.
-Rich

"Steven Livingstone" <s.***********@nospam.btinternet.com> wrote in message
news:uT**************@TK2MSFTNGP12.phx.gbl...

Rich - how big does you Xml doc get?
To be honest I was very happy with the SqlXml and Bulk Upload stuff for this kind of work - mainly as it does a lot of the stuff for you. It also
supports transactions if required and itself runs transactionally when bulk uploading.
Have you looked at that? It might be overkill if your document isn''t too
large, but even for reasonable sized documents i found it to be much better than writing streams of code.

Have a look at the post "Automagically create database schema from XML
dataset" from Fed 2nd for more info.

Steven
Founder, http://venturetogether.com

"Rich Wallace" <as**@qwerty.com> wrote in message
news:uJ*************@TK2MSFTNGP12.phx.gbl...

Hey all,

I have an XML doc that I read into a SQL Server database from an


integration

feed....

----------------XML snippet ----------------
<?xml version="1.0" encoding="us-ascii"?>
<!--Product data from JDEdwards-->
<Root>
<Root RvcDate="2004-02-03" RcvTime="14.16.03.795135">
<Product>
<File>1234A</File>
<Library>XCOMM</Library>
<ActionCode>A</ActionCode>
<TransDate>2004-02-03</TransDate>
<TransTime>14.18.39.337626</TransTime>
<Details Name="JBMCUS" Value="1234567890" />
<Details Name="JBALOT" Value="1234" />
<Details Name="JBSEQ2" Value="00856" />
<Details Name="JBLTP" Value="123456.00" />
<Details Name="JBADD1" Value="1234 Garrity Way" />
<Details Name="JBDL01" Value="" />
<Details Name="JBRDJ" Value="000000" />
<Details Name="JBFD01" Value="" />
<Details Name="JBUSD1" Value="000000" />
</Product>
<Product>
<File>1234B</File>
<Library>XCOMM</Library>
<ActionCode>A</ActionCode>
<TransDate>2004-02-03</TransDate>
<TransTime>14.18.39.337923</TransTime>
<Details Name="JBMCUS" Value="1234567890" />
<Details Name="JBALOT" Value="4567" />
<Details Name="JBSEQ2" Value="00856" />
<Details Name="JBLTP" Value="123456.00" />
<Details Name="JBADD1" Value="4567 Garrity Way" />
<Details Name="JBDL01" Value="" />
<Details Name="JBRDJ" Value="000000" />
<Details Name="JBFD01" Value="" />
<Details Name="JBUSD1" Value="000000" />
</Product>
<Product>
<File>1234A</File>
<Library>XCOMM</Library>
<ActionCode>A</ActionCode>
<TransDate>2004-02-03</TransDate>
<TransTime>14.18.39.412541</TransTime>
<Details Name="JBMCUS" Value="1234567890" />
<Details Name="JBALOT" Value="9876" />
<Details Name="JBSEQ2" Value="00856" />
<Details Name="JBLTP" Value="123456.00" />
<Details Name="JBADD1" Value="9876 Main St" />
<Details Name="JBDL01" Value="" />
<Details Name="JBRDJ" Value="000000" />
<Details Name="JBFD01" Value="" />
<Details Name="JBUSD1" Value="000000" />
</Product>
</Root>
</Root>
----------------End XML snippet ----------------

Currently, I load the XML into a dataset and loop on each datarow in the
dataset and process each row as an individual transaction. I''m curious to know if there is a ''standard'' approach on completing the goal and if the
path I''ve selected if efficient or is there a better way?

Suggestions or any kind of feedback would be appreciated.

TIA
-Rich




We had a similar situation on a project i worked on a while back.
We used the following solution.

1. Accept files as Xml.
2. Use XPath''s to process our business rules - multiple XPaths were used
typically. Sometimes you had to call out to a custom class, but not often.
3. Transformed our Xml to a Bulk Upload format.
4. Passed it in.

3 and 4 for you could easily be SqlXml and use your Stored Prcos from there.
It is just much easier IMO to push Xml directly to sql - even via SP''s,
rather than progratically.

Cool articles here http://sightkeys.com?181 and here
http://sightkeys.com?182

Best of luck with whatever method you choose.

Steven
Founder, http://venturetogether.com
"Rich Wallace" <as**@qwerty.com> wrote in message
news:Ov**************@TK2MSFTNGP09.phx.gbl...

Hi Steven,

The XML document that I accept can contain anywhere from 1 <Product> to 500. Unfortunately, what I need to do isn''t as simple as doing a bulk load as I
have to perform several business rules and other checks and balances before the data gets pushed to SQL. The way I drive the data into the database is via parameterized stored procedures so I don''t actually push XML data into
the table, rather parsed out data from the XML.

I feel that working with datasets are quite fast and efficient but I always question my selection as the standby ''There has to be a better way!!!"

Thanks for your input.
-Rich

"Steven Livingstone" <s.***********@nospam.btinternet.com> wrote in message news:uT**************@TK2MSFTNGP12.phx.gbl...

Rich - how big does you Xml doc get?
To be honest I was very happy with the SqlXml and Bulk Upload stuff for this

kind of work - mainly as it does a lot of the stuff for you. It also
supports transactions if required and itself runs transactionally when


bulk

uploading.
Have you looked at that? It might be overkill if your document isn''t too
large, but even for reasonable sized documents i found it to be much


better

than writing streams of code.

Have a look at the post "Automagically create database schema from XML
dataset" from Fed 2nd for more info.

Steven
Founder, http://venturetogether.com

"Rich Wallace" <as**@qwerty.com> wrote in message
news:uJ*************@TK2MSFTNGP12.phx.gbl...

Hey all,

I have an XML doc that I read into a SQL Server database from an


integration

feed....

----------------XML snippet ----------------
<?xml version="1.0" encoding="us-ascii"?>
<!--Product data from JDEdwards-->
<Root>
<Root RvcDate="2004-02-03" RcvTime="14.16.03.795135">
<Product>
<File>1234A</File>
<Library>XCOMM</Library>
<ActionCode>A</ActionCode>
<TransDate>2004-02-03</TransDate>
<TransTime>14.18.39.337626</TransTime>
<Details Name="JBMCUS" Value="1234567890" />
<Details Name="JBALOT" Value="1234" />
<Details Name="JBSEQ2" Value="00856" />
<Details Name="JBLTP" Value="123456.00" />
<Details Name="JBADD1" Value="1234 Garrity Way" />
<Details Name="JBDL01" Value="" />
<Details Name="JBRDJ" Value="000000" />
<Details Name="JBFD01" Value="" />
<Details Name="JBUSD1" Value="000000" />
</Product>
<Product>
<File>1234B</File>
<Library>XCOMM</Library>
<ActionCode>A</ActionCode>
<TransDate>2004-02-03</TransDate>
<TransTime>14.18.39.337923</TransTime>
<Details Name="JBMCUS" Value="1234567890" />
<Details Name="JBALOT" Value="4567" />
<Details Name="JBSEQ2" Value="00856" />
<Details Name="JBLTP" Value="123456.00" />
<Details Name="JBADD1" Value="4567 Garrity Way" />
<Details Name="JBDL01" Value="" />
<Details Name="JBRDJ" Value="000000" />
<Details Name="JBFD01" Value="" />
<Details Name="JBUSD1" Value="000000" />
</Product>
<Product>
<File>1234A</File>
<Library>XCOMM</Library>
<ActionCode>A</ActionCode>
<TransDate>2004-02-03</TransDate>
<TransTime>14.18.39.412541</TransTime>
<Details Name="JBMCUS" Value="1234567890" />
<Details Name="JBALOT" Value="9876" />
<Details Name="JBSEQ2" Value="00856" />
<Details Name="JBLTP" Value="123456.00" />
<Details Name="JBADD1" Value="9876 Main St" />
<Details Name="JBDL01" Value="" />
<Details Name="JBRDJ" Value="000000" />
<Details Name="JBFD01" Value="" />
<Details Name="JBUSD1" Value="000000" />
</Product>
</Root>
</Root>
----------------End XML snippet ----------------

Currently, I load the XML into a dataset and loop on each datarow in the dataset and process each row as an individual transaction. I''m curious to

know if there is a ''standard'' approach on completing the goal and if


the path I''ve selected if efficient or is there a better way?

Suggestions or any kind of feedback would be appreciated.

TIA
-Rich





这篇关于最佳实践 - XML处理??的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆