XML定义最佳实践 [英] XML definitions best practices

查看:83
本文介绍了XML定义最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据块代表地图上的位置

它有以下字段:

X,Y,索引。

xml将在C#App中使用

什么是最佳实践方式

用xml定义这些数据:

1. br />

 <   location  >  
< X >
100
< / X >
< >
200
< / Y >
< 索引 >
4
< /索引 >
< / location



2.

 <   location  >  
X = 100
Y = 200
索引= 4
< / location >

解决方案

查看 xml-attributes-vs-元素 [ ^ ]


我认为第一种方法是最好的。这将使你的xml解析变得容易。



< location>

< X> 100< / X>

< Y> 200< / Y>

< Index> 4< / Index>

< / location>


第二个它只是不可接受的时期。是否要将演示的单个文本节点解析为三个参数?你怎么看,XML解析器用于什么? (但是,有时会使用这种做法,如果文字很大,并且解析器已经可用......)



-SA

I have a block of data that represents a location on a map
It has the following fields:
X, Y, Index.
The xml will be used in C# App
What is the best practice way
to define this data in xml:
1.

<location>
  <X>
    100
  </X>
  <Y>
    200
  </Y>
  <Index>
    4
  </Index>
</location


2.

<location>
   X=100
   Y=200
   Index=4
</location>

解决方案

Have a look at xml-attributes-vs-elements[^]


I think the first approach is best. This will make your xml parsing easy as well.

<location>
<X>100</X>
<Y>200</Y>
<Index>4</Index>
</location>


Second one it simply unacceptable, period. Do you want to parse the single text node you demonstrated into three parameters? And what do you think, what the XML parser is used for? (However, such practice is sometimes used, if the text is really big, and the parser is already available…)

—SA


这篇关于XML定义最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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