[英]How to split and store XML in SQL Server 2008 R2 using C#?
<?xml version="1.0" encoding="UTF-8"?>
<searchResult>
<pagination>
<itemsPerPage>{Number of Inventories per Page}</itemsPerPage>
<numberOfItems>{Number of Inventories}</numberOfItems>
</pagination>
<itemList>
<item>
{Requested Salesforce fields e.g:}
<Id>{Salesforce Id}</Id>
<Name>{Name}</Name>
<pb__IsForSale__c>{e.g.}false</pb__IsForSale__c>
<pb__IsForLease__c>{e.g.}true</pb__IsForLease__c>
<pb__ItemDescription__c>{Item Description}</pb__ItemDescription__c>
<pb__PurchaseListPrice__c>{Item List Price e.g.:}2000000.00</pb__PurchaseListPrice__c>
<CurrencyIsoCode>{Currency Iso Code e.g:}EUR</CurrencyIsoCode>
<pb__UnitBedrooms__c>{Number of Bedrooms}</pb__UnitBedrooms__c>
<asset>
<Id>{internal Propertybase InventoryAsset Id}</Id>
<category>{Images, Videos or Documents}</category>
<isExternalLink>false</isExternalLink>
<title>{title}</title>
<filename>{original name of the uploaded file}</filename>
<url>{full url to image/video/document}</url>
<thumbnailUrl>{full url to thumbnail image}</thumbnailUrl>
<midresUrl>{full url to thumbnail image}</midresUrl>
<tags>{comma separated tags}</tags>
<mimeType>{e.g. image/jpeg}</mimeType>
</asset>
<asset>
<Id>{internal Propertybase InventoryAsset Id}</Id>
<category>{Images, Videos or Documents}</category>
<isExternalLink>true</isExternalLink>
<title>{title}</title>
<url>{full url to image/video/document}</url>
<tags>{comma separated tags}</tags>
</asset>
<asset>
{...}
</asset>
{more assets ...}
</item>
<item>
{...}
</item>
{more items ...}
</itemList>
</searchResult>
好吧,我有上面的XML,我需要从中将item标记及其子节点作为属性存储在数据库表中,并且必须将资产标签及其子节点存储在另一个表中,其中item id作为来自数据库的外键。项目表,我该怎么做,做了很多糊涂,但无法获得使其正常工作的方法
您只需要选择所有Item
节点。
使用XPath(例如,带有SelectNodes
)将是\\\\Item
SelectNodes
这将产生一个可以迭代的节点集。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.