从app.config中读取XML并与XML文档进行比较 [英] Read XML from app.config and compare with a XML document

查看:169
本文介绍了从app.config中读取XML并与XML文档进行比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一些传入的XML文档,我需要检查在即将到来的XML中可配置的属性,如果要检查的XML文档中不存在该属性,请添加它.

要检查的属性将在app.config文件中指定,例如 OrderRequest.orderDetails.orderSummary.testCount ,我需要检查testCount属性是否存在于OrderRequest元素下.如果为否",则将其以及在app.config
中指定的值一起添加
收录XML->从app.config中读取需要在此XML文件中检查的属性->使用XDocument读取传入的XML->如果incomg XML中没有该属性,则将其添加到XML.

关于如何进行此操作的任何想法.

Hi
I have some incoming XML documents, I need to check attributes that are configurable in this coming XML and if the attribute is not there in the XML document being checked add it.

The attributes to be checked will be specified in the app.config file eg.OrderRequest.orderDetails.orderSummary.testCount, I need to check if the testCount attribute exists under the element OrderRequest. If No add it along with it’s value which is also specified in the app.config

INCOMING XML --> Read the attributes from the app.config which need to be checked in this XML file --> Read the incoming XML using XDocument --> If the attribute is not there in the incomg XML add it to the XML.

Any ideas how I can go on this.

推荐答案

使用^ ]用于读取和检查XML文件,并在需要时添加或更改值.

请参阅查询XML树上的简单示例 [向XML树添加元素,属性和节点 [
Use LINQ to XML[^] for reading and checking the XML file, and if needed added or change values.

See simple examples on Querying XML Trees[^] and Adding Elements, Attributes, and Nodes to an XML Tree[^]


这篇关于从app.config中读取XML并与XML文档进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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