Xml存储库实现 [英] Xml Repository Implementation

查看:65
本文介绍了Xml存储库实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将我的数据存储在XML文件中并且不知道如何实现XML存储库。我搜索了整个谷歌,但找不到它。


其实我正在寻找一个简单的Xml存储库(GetAll,添加,更新,删除)。



<?xml version =" ; 1.0" encoding =" utf-8"?>

< Entities xmlns:xsi =" http://www.w3.org/2001/XMLSchema-instance"的xmlns:XSD = QUOT; HTTP://www.w3.org/2001/XMLSchema" xmlns =" LicenseStore.Models">

  <订阅者>

  &NBSP; < Subscriber SubscriberId =" 1"产品代码= QUOT; ProductCode1" SubscriptionDateTime = QUOT;二○一八年十一月一十五日"状态= QUOT;真" />

  &NBSP; < Subscriber SubscriberId =" 2"产品代码= QUOT; ProductCode2" SubscriptionDateTime = QUOT;二○一八年十一月一十五日"状态= QUOT;真" />

  < / Subscribers>

< / Entities>


解决方案

您好, 


通常我代表元素和使用集合 - 序列化用于以XML格式存储集合。


但是如果你想直接处理存储库 - 使用XmlDocument作为基础,使用XPath进行过滤。


I need to store my data on a XML file and don't know how to implement a XML repository. I've searched all over the google and cannot find it.

Actually I'm looking for a simple Xml Repository(GetAll, Add, Update, Delete).

<?xml version="1.0" encoding="utf-8"?>
<Entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="LicenseStore.Models">
  <Subscribers>
    <Subscriber SubscriberId="1" ProductCode="ProductCode1" SubscriptionDateTime="2018-11-15" Status="true" />
    <Subscriber SubscriberId="2" ProductCode="ProductCode2" SubscriptionDateTime="2018-11-15" Status="true" />
  </Subscribers>
</Entities>

解决方案

Hello, 

Usually I do representation of elements and work with collection - serialization are used to store collection in XML format.

But if you want to dealing directly with repository - use XmlDocument as base and XPath for filtration.


这篇关于Xml存储库实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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