如何通过比较2个xml文件找到丢失的子标签? [英] How to find a missing child tag by comparing 2 xml files?

查看:75
本文介绍了如何通过比较2个xml文件找到丢失的子标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过比较2个xml文件找到丢失的子标记?



我有一个参考Xml。将通过服务提供输入xml。我想将此输入Xml与Reference Xml进行比较,并获取丢失的子标记(如果有的话)。

How to find a missing child tag by comparing 2 xml files?

I am having a reference Xml. There will be an input xml coming via service. I want to compare this input Xml with the Reference Xml and get the missing child tag if any.

推荐答案

很难分辨到目前为止您没有看到的代码。

如果我有这样的要求,我会去创建一个XML模式定义(.xsd)文件,我将用它来验证XML文件。比比较两个XML文件以找到差异更有效。



以下是一些关于XSD的参考网站:

XML Schema - Wikipedia [ ^ ]

W3C XML架构定义语言(XSD)1.1 [< a href =http://www.w3.org/TR/xmlschema11-1/target =_ blank> ^ ]

XML图式教程 - w3schools [ ^ ]
Hard to tell without seeing which code you have so far.
If I had such a requirement, I would go for creating a XML schema definition (.xsd) file, that I would use for validating the XML file. Much more efficient than comparing two XML files for finding differences.

Here are some reference sites about XSD:
XML Schema - Wikipedia[^]
W3C XML Schema Definition Language (XSD) 1.1[^]
XML Schema Tutorial - w3schools[^]


首先,您需要为xml文件创建一个模式文件。在模式文件中,xml文件的外观如何以及标记和元素应呈现的内容。通过以下链接了解如何为xml数据创建模式和规则。



http ://www.w3schools.com/schema/ [ ^ ]



然后,您需要使用架构验证服务xml数据。请通过以下链接查看如何使用架构(xsd)验证xml数据。



http://www.c-sharpcorner.com/UploadFile/87b416/validating-an-xml-document-programmatically/ [ ^ ]
Firstly you need create a schema file for your xml file. In schema file how your xml file looks like and what are tags and elements should present. Go through below link how to create schema and rules for xml data.

http://www.w3schools.com/schema/[^]

Then you need to validate service xml data with the schema. Please go through below link how to validate xml data with schema(xsd).

http://www.c-sharpcorner.com/UploadFile/87b416/validating-an-xml-document-programmatically/[^]


这篇关于如何通过比较2个xml文件找到丢失的子标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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