1

数据库 A 包含每个城市及其体育场的足球俱乐部和板球俱乐部列表。我为给定的本体编写了一个模糊的 XML 结构。但是结构中有错误。我无法在 XML 中找到错误。可以有人指出这个错误吗?

<?xml version='1.0'?>
<City>
<Name>London</Name>

    <Football_clubs>
        <club_details>
            <name>Chelsea FC</name>
            <stadium>Stamford Bridge</stadium>
        </club_details>
        <club_details>
            <name>Fulham</name>
            <stadium>Craven Cottage</stadium>
        </club_details>
        <club_details>
            <name>Spurs</name>
            <stadium>WHL</stadium>
        </club_details>
    </Football_clubs>
    <Cricket_Clubs>
        <club_details>
            <name>Yorkshire</name>
            <stadium>XYZ</stadium>
        </club_details>
        <club_details>
            <name>Leicetshire</name>
            <stadium>ABC</stadium>
        </club_details>
        <club_details>
            <name>Surrey</name>
            <stadium>GHI</stadium>
        </club_details>
    </Cricket_Clubs>


 </City>


 <City>
<Name>Manchester</Name>

    <Football_clubs>
        <club_details>
            <name>Manchester Utd</name>
            <stadium>Old Trafford</stadium>
        </club_details>
        <club_details>
            <name>Manchester City</name>
            <stadium>Maine Road</stadium>
        </club_details>
        <club_details>
            <name>Bolton</name>
            <stadium>SDF</stadium>
        </club_details>
    </Football_clubs>
    <Cricket_Clubs>
        <club_details>
            <name>Yorkshire</name>
            <stadium>XYZ</stadium>
        </club_details>
        <club_details>
            <name>Leicetshire</name>
            <stadium>ABC</stadium>
        </club_details>
        <club_details>
            <name>Surrey</name>
            <stadium>GHI</stadium>
        </club_details>
    </Cricket_Clubs>


  </City>
4

1 回答 1

2

肯定缺少根元素:

“每个 XML 文档只有一个根元素。这个元素也称为文档元素。它包含所有其他元素,因此是所有其他元素的唯一父元素。” - 维基

应该:

<?xml version='1.0'?>
<cities>
    <city>
        ...contents
    </city>
    <city>
        ...contents
    </city>
</cities>
于 2012-10-16T22:12:14.003 回答