草庐IT

xml - (XML) 文档中跟在根元素之后的标记必须格式正确。起始位置 : 6:2

coder 2024-06-23 原文

<分区>

刚开始学习我的 XML 类(class),但在找到解决我的错误的方法时遇到了一些麻烦。我收到此错误:“文档中跟在根元素之后的标记必须格式正确。 开始位置:6:2"。

任何类型的提示或帮助都会很棒。

 <?xml version="1.0" encoding="UTF-8"?>
 <heading>
 The Twelve Days of Christmas
 </heading>

<song> //OxyGen highlights "<song>" as the error, but i'm not sure I understand.
    <Day ="One"> 
        <verse>
    On the first day of Christmas, my true love sent to me, a partridge in a pear tree.
        </verse>
    </Day>

    <Day="Two">
        <verse>
     On the second day of Christmas, my true love sent to me 
     Two turtle doves 
     and a partridge in a pear tree. 
        </verse>
    </Day>

     <Day="Three"> 
         <verse>
     On the third day of Christmas, my true love sent to me 
     Three French hens, 
     two turtle doves 
     And a partridge in a pear tree.
         </verse>
     </Day>

     <Day="Four">
         <verse>
     On the fourth day of Christmas, my true love sent to me 
     Four calling birds, 
     three French hens, 
     two turtle doves 
     And a partridge in a pear tree. 
         </verse>
     </Day>

     <Day="Fifth">
         <verse>
     On the fifth day of Christmas, my true love sent to me 
     Five golden rings. 
     Four calling birds, 
     three French hens, 
     two turtle doves 
     And a partridge in a pear tree.
         </verse>
     </Day>

     <Day="Sixth">
         <verse>
     On the sixth day of Christmas, my true love gave to me 
     Six geese a-laying, 
     Five golden rings. 
     Four calling birds, 
     three French hens, 
     two turtle doves 
     And a partridge in a pear tree. 
         </verse>
     </Day>

     <Day="Seventh">
         <verse>
     On the seventh day of Christmas, my true love gave to me 
     Seven swans a-swimming, 
     six geese a-laying, 
     Five golden rings. 
     Four calling birds, 
     three French hens, 
     two turtle doves 
     And a partridge in a pear tree. 
         </verse>
     </Day>

     <Day="Eighth">
         <verse>
     On the eighth day of Christmas, my true love gave to me 
     Eight maids a-milking, 
     seven swans a-swimming, 
     six geese a-laying, 
     Five golden rings. 
     Four calling birds, 
     three French hens, 
     two turtle doves 
     And a partridge in a pear tree. 
         </verse>
     </Day>

     <Day="Ninth">
         <verse>
     On the ninth day of Christmas, my true love gave to me 
     Nine ladies dancing, 
     eight maids a-milking, 
     seven swans a-swimming, 
     six geese a-laying, 
     Five golden rings. 
     Four calling birds, 
     three French hens, 
     two turtle doves 
     And a partridge in a pear tree. 
         </verse>
     </Day>

     <Day="Tenth">
         <verse>
     On the tenth day of Christmas, my true love gave to me 
     Ten lords a-leaping, 
     nine ladies dancing, 
     eight maids a-milking, 
     seven swans a-swimming, 
     six geese a-laying, 
     Five golden rings. 
     Four calling birds, 
     three French hens, 
     two turtle doves 
     And a partridge in a pear tree. 
         </verse>
     </Day>

     <Day="Eleventh">
         <verse>
     On the eleventh day of Christmas, my true love gave to me 
     Eleven pipers piping, 
     ten lords a-leaping, 
     nine ladies dancing, 
     eight maids a-milking, 
     seven swans a-swimming, 
     six geese a-laying, 
     Five golden rings. 
     Four calling birds, 
     three French hens, 
     two turtle doves 
     And a partridge in a pear tree. 
         </verse>
     </Day>

     <Day="Twelfth">
         <verse>
     On the twelfth day of Christmas, my true love gave to me 
     Twelve drummers drumming, 
     eleven pipers piping, 
     ten lords a-leaping, 
     nine ladies dancing, 
     eight maids a-milking, 
     seven swans a-swimming, 
     six geese a-laying, 
     Five golden rings. 
     Four calling birds, 
     three French hens, 
     two turtle doves 
     And a partridge in a pear tree. 
         </verse>
     </Day>

 </song>

有关xml - (XML) 文档中跟在根元素之后的标记必须格式正确。起始位置 : 6:2的更多相关文章

  1. ruby-on-rails - 如何从 format.xml 中删除 <hash></hash> - 2

    我有一个对象has_many应呈现为xml的子对象。这不是问题。我的问题是我创建了一个Hash包含此数据,就像解析器需要它一样。但是rails自动将整个文件包含在.........我需要摆脱type="array"和我该如何处理?我没有在文档中找到任何内容。 最佳答案 我遇到了同样的问题;这是我的XML:我在用这个:entries.to_xml将散列数据转换为XML,但这会将条目的数据包装到中所以我修改了:entries.to_xml(root:"Contacts")但这仍然将转换后的XML包装在“联系人”中,将我的XML代码修改为

  2. ruby - 在哈希的键数组中追加元素 - 2

    查看我的Ruby代码:h=Hash.new([])h[0]=:word1h[1]=h[1]输出是:Hash={0=>:word1,1=>[:word2,:word3],2=>[:word2,:word3]}我希望有Hash={0=>:word1,1=>[:word2],2=>[:word3]}为什么要附加第二个哈希元素(数组)?如何将新数组元素附加到第三个哈希元素? 最佳答案 如果您提供单个值作为Hash.new的参数(例如Hash.new([]),完全相同的对象将用作每个缺失键的默认值。这就是您所拥有的,那是你不想要的。您可以改用

  3. Matlab imread()读到了什么 (浅显 当复习文档了) - 2

    matlab打开matlab,用最简单的imread方法读取一个图像clcclearimg_h=imread('hua.jpg');返回一个数组(矩阵),往往是a*b*cunit8类型解释一下这个三维数组的意思,行数、数和层数,unit8:指数据类型,无符号八位整形,可理解为0~2^8的数三个层数分别代表RGB三个通道图像rgb最常用的是24-位实现方法,即RGB每个通道有256色阶(2^8)。基于这样的24-位RGB模型的色彩空间可以表现256×256×256≈1670万色当imshow传入了一个二维数组,它将以灰度方式绘制;可以把图像拆分为rgb三层,可以以灰度的方式观察它figure(1

  4. 「Python|Selenium|场景案例」如何定位iframe中的元素? - 2

    本文主要介绍在使用Selenium进行自动化测试或者任务时,对于使用了iframe的页面,如何定位iframe中的元素文章目录场景描述解决方案具体代码场景描述当我们在使用Selenium进行自动化测试的时候,可能会遇到一些界面或者窗体是使用HTML的iframe标签进行承载的。对于iframe中的标签,如果直接查找是无法找到的,会抛出没有找到元素的异常。比如近在咫尺的例子就是,CSDN的登录窗体就是使用的iframe,大家可以尝试通过F12开发者模式查看到的tag_name,class_name,id或者xpath来定位中的页面元素,会抛出NoSuchElementException异常。解决

  5. ruby - 正则表达式在哪个位置失败? - 2

    我需要一个非常简单的字符串验证器来显示第一个符号与所需格式不对应的位置。我想使用正则表达式,但在这种情况下,我必须找到与表达式相对应的字符串停止的位置,但我找不到可以做到这一点的方法。(这一定是一种相当简单的方法……也许没有?)例如,如果我有正则表达式:/^Q+E+R+$/带字符串:"QQQQEEE2ER"期望的结果应该是7 最佳答案 一个想法:你可以做的是标记你的模式并用可选的嵌套捕获组编写它:^(Q+(E+(R+($)?)?)?)?然后你只需要计算你获得的捕获组的数量就可以知道正则表达式引擎在模式中停止的位置,你可以确定匹配结束

  6. ruby - Hanami link_to 助手只呈现最后一个元素 - 2

    我是HanamiWorld的新人。我已经写了这段代码:moduleWeb::Views::HomeclassIndexincludeWeb::ViewincludeHanami::Helpers::HtmlHelperdeftitlehtml.headerdoh1'Testsearchengine',id:'title'hrdiv(id:'test')dolink_to('Home',"/",class:'mnu_orizontal')link_to('About',"/",class:'mnu_orizontal')endendendendend我在模板上调用了title方法。htm

  7. ruby - 将n维数组的每个元素乘以Ruby中的数字 - 2

    在Ruby中,是否有一种简单的方法可以将n维数组中的每个元素乘以一个数字?这样:[1,2,3,4,5].multiplied_by2==[2,4,6,8,10]和[[1,2,3],[1,2,3]].multiplied_by2==[[2,4,6],[2,4,6]]?(很明显,我编写了multiplied_by函数以区别于*,它似乎连接了数组的多个副本,不幸的是这不是我需要的)。谢谢! 最佳答案 它的长格式等价物是:[1,2,3,4,5].collect{|n|n*2}其实并没有那么复杂。你总是可以使你的multiply_by方法:c

  8. arrays - 计算数组中的匹配元素 - 2

    给定两个大小相等的数组,如何找到不考虑位置的匹配元素的数量?例如:[0,0,5]和[0,5,5]将返回2的匹配项,因为有一个0和一个5共同;[1,0,0,3]和[0,0,1,4]将返回3的匹配项,因为0有两场,1有一场;[1,2,2,3]和[1,2,3,4]将返回3的匹配项。我尝试了很多想法,但它们都变得相当粗糙和令人费解。我猜想有一些不错的Ruby习惯用法,或者可能是一个正则表达式,可以很好地回答这个解决方案。 最佳答案 您可以使用count完成它:a.count{|e|index=b.index(e)andb.delete_at

  9. ruby - 下载位置 Selenium-webdriver Cucumber Chrome - 2

    我将Cucumber与Ruby结合使用。通过Selenium-Webdriver在Chrome中运行测试时,我想将下载位置更改为测试文件夹而不是用户下载文件夹。我当前的chrome驱动程序是这样设置的:Capybara.default_driver=:seleniumCapybara.register_driver:seleniumdo|app|Capybara::Selenium::Driver.new(app,:browser=>:chrome,desired_capabilities:{'chromeOptions'=>{'args'=>%w{window-size=1920,1

  10. ruby - 变量赋值后的 if 语句 - 有多常见? - 2

    我最近与一位同事讨论了以下Ruby语法:value=ifa==0"foo"elsifa>42"bar"else"fizz"end我个人并没有看到太多这种逻辑,但我的同事指出,这实际上是一种相当普遍的Rubyism。我试着用谷歌搜索这个主题,但没有找到任何文章、页面或SO问题来讨论它,这让我相信这可能是一种非常实际的技术。然而,另一位同事发现语法令人困惑,而是将上面的逻辑写成这样:ifa==0value="foo"elsifa>42value="bar"elsevalue="fizz"end缺点是value=的重复声明和隐式elsenil的丢失,如果我们想使用它的话。这也感觉它与Ruby

随机推荐