附加到XML .......... [英] Appending to XML..........

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

问题描述

大家好,

尝试加载
时出现此错误 xml文件:

Hi all,

I am getting this error when I am trying to load an
xml file:

Data at the root level is invalid. Line 1, position 1.



这是我使用的代码:



This is my code I used:

XmlDocument SAP_SettingsXML = new XmlDocument();
            SAP_SettingsXML.LoadXml(SAP_Manager.PublicVariables.clsPublicVariables.SettingsPath);

            XmlNode node = SAP_SettingsXML.CreateNode(XmlNodeType.Element, "OutboundPath", null);
            node.InnerText = txt_DirectoryPath.Text;

            //add to elements collection
            SAP_SettingsXML.DocumentElement.AppendChild(node);

            SAP_SettingsXML.Save(SAP_Manager.PublicVariables.clsPublicVariables.SettingsPath);



这是我的xml文件内容:



Here is my xml File content:

<?xml version="1.0" encoding="utf-8"?>
<SAP_Manager_Settings>
<Inbound_Path xmlns=" ">C:\Users\Ben\Desktop</Inbound_Path><

/SAP_Manager_Settings>



请提供任何帮助!



Please any help would be appriciated!!

推荐答案

根级别的数据无效.第1行,位置1.
查看您的XML文件格式是否正确.确保根标记之前的顶部没有空格或换行.
Data at the root level is invalid. Line 1, position 1.
See if your XML file is properly formed. Make sure there is no space or new line at the top before the root tag.


您的XML格式不正确,但是您在制定问题时可能会用HTML格式设置不好.错误出现在最后两行中:当您破坏''<''和``/''时,它们之间不能有新的行定界符.

—SA
Your XML is not well-formed, but perhaps you just poorly formatted it in HTML while formulating the question. The error is in last two lines: there must not be a new line delimiter between them, as you break ''<'' and ''/''.

—SA


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

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