首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >XML实例有错误的父元素。

XML实例有错误的父元素。
EN

Stack Overflow用户
提问于 2022-04-17 06:10:27
回答 1查看 46关注 0票数 0

我刚刚开始学习XML,但在我正在学习的教材中不断出现这个错误:

The element at this point in your instance has the wrong parent element. Most likely it is next to rather than inside the parent tag.

这就是我的代码的结构方式。

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<infoAssets>
<companyName></companyName>
    <products>
     <product/> <title/>  <description/><specification/>
    </products>
    <services>
        <service/>
        <title/>
        <description/>
    </services>    
</infoAssets>

我不明白孩子在父母之外的什么地方。

EN

回答 1

Stack Overflow用户

发布于 2022-04-17 22:12:29

我认为问题在于XML文件的结构,而不是验证。<title><description><specification> at <products><services>不包括在正确的节点上,因为父节点<product><service>是空的,因为<product/><service/>是空的。

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<infoAssets>
    <companyName></companyName>    
</infoAssets>
<products>
    <product>
        <title/>
        <description/>
        <specification/>
    </product>
</products>
<services>
    <service>
        <title/>
        <description/>
    </service>
</services>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71899702

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档