问题描述
是否可以根据XML
内容创建您的赢得XSD以用于.NET?
例如下面的那个:
<?xml version =" 1.0"?>
< pcats:FuelsDoc
xmlns =" http:// www .naxml.org / Retail-EDI / Vocabulary / 2003-10-16"
xmlns:xsi =" http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation =" NAXML-FuelPrice15.xsd">
< pcats:TransmissionHeader>
< pcats:TransmissionId> 200706040938< / pcats:TransmissionId>
< pcats:TransmissionDate> 2007-06-04< / pcats:TransmissionDate>
< pcats:TransmissionTime> 09:38:19-06 :00< / pcats:TransmissionTime>
< pcats:TransmissionStatus> original< / pcats:TransmissionStatus>
< pcats:TransmissionSender> Apex Oil< / pcats:TransmissionSender> ;
< pcats:TransmissionAgency> DTN Integrated
服务/ dtnDataConnec t< / pcats:TransmissionAgency>
< / pcats:TransmissionHeader>
< pcats:FuelPriceInfo>
< pcats:Terminal>
< pcats:Name identType =" PlantNumber" ident =" 1070">
< pcats:NamePrefix> Frsn KMEP< / pcats:NamePrefix>
< / pcats:Name>
< pcats:City> Fresno< / pcats:City>
< pcats:State> CA< / pcats:State>
< pcats:FuelProduct> ;< pcats:EffectiveDate> 2007-06-04< / pcats:EffectiveDate>
< pcats:EffectiveTime> 10:00:00< / pcats:EffectiveTime>
< pcats:FuelProductId identType ="超低硫CARB
#2"> 0402< / pcats:FuelProductId>
< pcats:Price> 2.240000< ; / pcats:价格>
< pcats:NetChange> .040000< / pcats:NetChange>
< / pcats:FuelProduct>
< / pcats:终端>
< / pcats:FuelPriceInfo>
< / pcats:FuelsDoc>
谢谢
比尔
Is it possible to create your won XSD to use with .NET based on an XML
content?
For example the one below:
<?xml version="1.0"?>
<pcats:FuelsDoc
xmlns="http://www.naxml.org/Retail-EDI/Vocabulary/2003-10-16"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="NAXML-FuelPrice15.xsd">
<pcats:TransmissionHeader>
<pcats:TransmissionId>200706040938</pcats:TransmissionId>
<pcats:TransmissionDate>2007-06-04</pcats:TransmissionDate>
<pcats:TransmissionTime>09:38:19-06:00</pcats:TransmissionTime>
<pcats:TransmissionStatus>original</pcats:TransmissionStatus>
<pcats:TransmissionSender>Apex Oil</pcats:TransmissionSender>
<pcats:TransmissionAgency>DTN Integrated
Services/dtnDataConnect</pcats:TransmissionAgency>
</pcats:TransmissionHeader>
<pcats:FuelPriceInfo>
<pcats:Terminal>
<pcats:Name identType="PlantNumber" ident="1070">
<pcats:NamePrefix>Frsn KMEP</pcats:NamePrefix>
</pcats:Name>
<pcats:City>Fresno</pcats:City>
<pcats:State>CA</pcats:State>
<pcats:FuelProduct><pcats:EffectiveDate>2007-06-04</pcats:EffectiveDate>
<pcats:EffectiveTime>10:00:00</pcats:EffectiveTime>
<pcats:FuelProductId identType="Ultra Low Sulfur CARB
#2">0402</pcats:FuelProductId>
<pcats:Price>2.240000</pcats:Price>
<pcats:NetChange>.040000</pcats:NetChange>
</pcats:FuelProduct>
</pcats:Terminal>
</pcats:FuelPriceInfo>
</pcats:FuelsDoc>
Thanks
Bill
推荐答案
.NET框架SDK有一个名为xsd.exe的工具,可以做到这一点。
和.NET框架(2.0及更高版本)有一个类XmlSchemaInference
有一个方法InferSchema:
< http://msdn2.microsoft.com/en-us/library/system .xml.schema.xmlschemainference.aspx>
-
Martin Honnen --- MVP XML
这篇关于如何基于XML文件内容创建XSD文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!