且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

所有父节点必须具有相同类型的子节点吗?

更新时间:2023-02-05 20:27:07

它在某种意义上是有效的,因为它遵循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().