从 XML 更新 SQL 表
我正在使用 InfoPath 2007 发送调查(它未连接到 SharePoint 或数据库)。我将返回的文件是一个 XML 文件。每个地方都有一个答案块,它有自己唯一的 id(也称为字段名称)。
现在,我有一个带有“Responses”表的 SQL Server 数据库(2007 年?)。它的列是:AnswerID(唯一的PK)、QuestionID(FK)(这是唯一的id(字段名称)和Answer。QuestionID已经填充了唯一的id(字段名称)。QuestionID有超过300条记录 。
我需要做的是进入 XML 文件,找到 QuestionID(字段名称),获取该字段名称的数据,然后将数据放入与字段名称匹配的数据库列“Answer”中 QuestionID 列。
是否有一种简单/中等的方法可以以最少的错误率进行此映射/更新?
注意:我尝试使用 DB 导入 XML 数据向导,但信息出现了问题。成数量难以管理的表。
I am using InfoPath 2007 to send out a survey (it is not connected to SharePoint or a DataBase). The file I will get back is an XML file. Every place there is an answer block, it has its own unique id (aka field name).
Now, I have a SQL Server Database (2007?) with a table "Responses". Its columns are: AnswerID(unique PK), QuestionID (FK) (which is the unique id (field name), and Answer. The QuestionID is already populated with the unique id (field name). There are more than 300 records for QuestionID.
What I need to be able to do is reach into the XML file, find the QuestionID (field name), grab the data for that field name, and then put the data into the DB column "Answer" that matches the field name in the QuestionID column.
Is there an easy/medium way to do this mapping/updating with the least amount of chance of error?
NOTE: I tried to use the DB import XML data wizard, the information breaks out into an unmanageable number of tables.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将 XML 分解为行和列,然后使用它来更新表。
这是您可以执行的操作的一个小示例。
结果:
我使用的 XML 肯定与您所拥有的完全不同,但它应该提示您可以做什么。如果您发布 XML 文件、表结构和预期结果/输出的示例,您可能会得到更准确的答案。
编辑
结果:
You can shred the XML into rows and columns and then use that to update your table.
Here is a little example of what you can do.
Result:
The XML I used most certainly does not look anything like what you have but it should give you a hint of what you can do. If you post a sample of your XML file, table structure and expected result/output you can probably get a more precise answer.
Edit
Result: