所有父节点必须具有相同类型的子节点吗? [英] Must all parent node have the same types of childs?

查看:92
本文介绍了所有父节点必须具有相同类型的子节点吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我想要一个横幅列表,所有都有一个名字,但不是所有人都说我可以写这个网址

For example, I want a list of banners, all will have a name, but not all say a url can I write this

展开 | 选择 | 换行 | 行号

推荐答案

它在某种意义上是有效的,因为它遵循XML基本规则(假设您使用UTF-8)。


用于更严格的验证,你需要一个DTD或Schema(XSD或RelaxNG)
it is valid in the sense as it follows the XML base rules (given that you use UTF-8).

for stricter validaty, you?d need a DTD or Schema (XSD or RelaxNG)


,除了DTD / UTF-8,因为我现在看到的所有内容都坚持在每个父节点中使用相同的子节点同名,有一些缺点/ disadvan用这个逻辑进行切换?

(在我的for循环中提取数据时,我打算使用一个简单的if来查看< url>孩子是否存在于每个父母身上)
aside from the DTD/UTF-8 because everything I have seen up to now sticks with the same childs in every parent node with the same name, is there some downside/disadvantange with this logic?
(When extracting data in my for loop I plan to use a simple if to see wheather the <url> child exists or not in each parent)


我认为这是个人偏好的问题。如果您只想要URL,请使用XPath或getElementsByTagName()。
I think it?s a matter of personal preference. if you want only the URLs, use XPath or getElementsByTagName().


这篇关于所有父节点必须具有相同类型的子节点吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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