无法在XML中实现名称空间 [英] Having trouble implementing namespaces in XML
本文介绍了无法在XML中实现名称空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在下面的代码中,我在"7.65GB"处收到错误,它不断告诉我元素"UMUC2:size"的前缀"UMUC2"未绑定".一切看起来正确,都无法找出问题所在.
Within the code below I am receiving an error at "7.65GB", it keeps telling me "The prefix "UMUC2" for element "UMUC2:size" is not bound". Everything looks correct cannot figure out the problem.
<?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>
推荐答案
在您的XML中,UMUC2
,UMUC3
和UMUC4
前缀的声明不正确.它们被解释为元素内容.
In your XML, the declarations for the UMUC2
, UMUC3
, and UMUC4
prefixes are not correct; they are interpreted as element content.
根元素上的名称空间声明必须看起来像这样(请注意已删除的直角括号):
The namespace declarations on the root element must look like this (note the removed right angle brackets):
<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">
这篇关于无法在XML中实现名称空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文