以文本方式查看主题

-  计算机科学论坛  (http://bbs.xml.org.cn/index.asp)
--  『 XML源码及示例(仅原创和转载) 』  (http://bbs.xml.org.cn/list.asp?boardid=32)
----  [求助]初学XML,大家帮我分析以下?  (http://bbs.xml.org.cn/dispbbs.asp?boardid=32&rootid=&id=29160)


--  作者:becky1983
--  发布时间:3/24/2006 9:53:00 AM

--  [求助]初学XML,大家帮我分析以下?
my.xml:
<?xml version="1.0" encoding="utf-8" ?>
<root>
   <resource name="Login">登录</resource>
    <resource name="Name">登录名</resource>
</root

调用程序如下:
public static string GetString(string Key)
{
    if(HttpContext.Current.Cache[Key] == null)
     {
       try
 {
     string ReturnValue = string.Empty;
     XmlDocument d = new XmlDocument();
     d.Load(ConfigurationSettings.AppSettings["LanguageConfigFile"]);
     foreach (XmlNode n in d.SelectSingleNode("root").ChildNodes)
     {
        if (n.NodeType != XmlNodeType.Comment)
         {
            if (n.Attributes["name"].Value.Trim() == Key)
             {                      ReturnValue = n.InnerText;     break;
             }
         }
      }
     HttpContext.Current.Cache.Insert(Key,ReturnValue);
 return ReturnValue;
            }
            catch(Exception ex)
           {
        return string.Empty;
           }
     }
     else return HttpContext.Current.Cache[Key].ToString();
  }

提示错误信息如下:
System.Xml.XmlException: 这是一个意外的标记。标记应为“TAGEND”。 行 6,位置 1。


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
23.438ms