在下面的代码中,我收到“7.65GB”的错误,它一直告诉我“前缀”UMUC2“元素”UMUC2:size“未绑定”。一切看起来都正确无法弄清楚问题。
<?xml version="1.0" encoding="UTF-8"?>
<!-- New document created with EditiX at Sat Jul 05 07:35:36 AST 2014 -->
<dataCollection xmlns:UMUC1="http://umuc.edu/namespaces/games">
xmlns:UMUC2="http://umuc.edu/namespaces/software">
xmlns:UMUC3="http://umuc.edu/namespaces/music">
xmlns:UMUC4="http://umuc.edu/namespaces/video">
<UMUC1:size>17.5GB</UMUC1:size>
<UMUC1:date_of_collection>01/01/2013</UMUC1:date_of_collection>
<UMUC1:collectionSite>www.google.com</UMUC1:collectionSite>
<UMUC2:size>7.65GB</UMUC2:size>
<UMUC2:date_of_collection>05/28/2013</UMUC2:date_of_collection>
<UMUC2:collectionSite>www.microsoft.com</UMUC2:collectionSite>
<UMUC3:size>100.5GB</UMUC3:size>
<UMUC3:date_of_collection>06/26/2013</UMUC3:date_of_collection>
<UMUC3:collectionSite>www.apple.com</UMUC3:collectionSite>
<UMUC4:size>1.75TB</UMUC4:size>
<UMUC4:date_of_collection>03/27/2014</UMUC4:date_of_collection>
<UMUC4:collectionSite>www.videox.com</UMUC4:collectionSite>
</dataCollection>
答案 0 :(得分:2)
在您的XML中,UMUC2
,UMUC3
和UMUC4
前缀的声明不正确;它们被解释为元素内容。
根元素上的名称空间声明必须如下所示(注意删除的右尖括号):
<dataCollection xmlns:UMUC1="http://umuc.edu/namespaces/games"
xmlns:UMUC2="http://umuc.edu/namespaces/software"
xmlns:UMUC3="http://umuc.edu/namespaces/music"
xmlns:UMUC4="http://umuc.edu/namespaces/video">