(错误)了解XML文件...... [英] (Mis-)Understanding XML files ...

查看:101
本文介绍了(错误)了解XML文件......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望有人可以告诉我我做错了什么...我之前从未使用过XML文件,所以我显然误解了一些东西......



此XML文件:



Hopefully somebody can tell me what I’m doing wrong … I’ve never used an XML file before, so I’m obviously misunderstanding something ...

This XML file :

<?xml version="1.0" encoding="utf-8" ?>
  <Folders>
    <TemplatesFolder>E:\Newsletter Templates (Email)\</TemplatesFolder>
    <NewsLetterFolder>E:\Newsletters\</NewsLetterFolder>
  </Folders>





通过以下代码阅读:





Read by this code :

Do While (myXml.Read())
    If myXml.IsStartElement() Then
        If myXml.Name = "TemplatesFolder" Then
            myXml.Read()
            myTempFolder = myXml.Value
        End If
        If myXml.Name = "NewsLetterFolder" Then
            myXml.Read()
            myNlFolder = myXml.Value
        End If
    End If
Loop





给出此错误:





Gives this error:

There are multiple root elements. Line 3, position 2.





我做错了什么?!?



What am I doing wrong ?!?

推荐答案

请参阅我对该问题的评论。我不确定您是否显示导致异常的相同文件。否则,如何在第二行解释你的缩进?



你不应该使用你正在使用的代码风格,但我知道你可能只是在试验。 />


这个例外基本上告诉你输入文件不是格式良好的XML。根XML元素始终只有一个。你可以删除你的prolog(第一行)。



-SA
Please see my comment to the question. I am not sure that you show the same very file which causes the exception. Otherwise, how to explain your indentation in second line?

The code style you are using should not be used anyway, but I understand that you maybe just experimenting.

This exception, essentially, tells you that your input file is not a well-formed XML. The root XML element is always only one. You can remove you prolog (first line).

—SA


这篇关于(错误)了解XML文件......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆