非法的xml字符[行:1位置:2] [英] illegal xml character [Line: 1 Position: 2]

查看:132
本文介绍了非法的xml字符[行:1位置:2]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Experts

我想知道是否有人可以在这里为我提供帮助.我在Silverlight4 Application中编写了像波纹管这样的代码,它基本上只是带回了xaml的xml格式,并且在我的代码中.我在运行时遇到错误..

非法xml字符[行:1位置:2]
这是使用...的客户端代码.

Hi Experts

Wondering if anyone can help me here,I have written code like bellow in silverlight4 Application ,it basically just brings back some xml format for xaml and in my code .i am getting below error while run time..

illegal xml character [Line: 1 Position: 2]
this is the client code im using...

public void LoadContent()
{
    OpenFileDialog openFileDialog1 = new OpenFileDialog();


    openFileDialog1.Filter = "XAML Files|*.xaml";
    bool? retval = openFileDialog1.ShowDialog();
    
    if (retval.HasValue && retval.Value)
    
        this.FilePath = openFileDialog1.File.Name;
        System.IO.Stream fileStream = openFileDialog1.File.OpenRead();

        object content = XamlReader.Load(fileStream.ToString());//falls over here             
        this.Content = content;
       
    }
}

推荐答案

问题可能出在
The problem might be with the
fileStream.ToString()



这不会将XAML作为字符串加载,而是"Sytem.IO.Filestream".我不习惯Silverlight,但我看到的示例应该使用



This will not load the XAML as a string, but "Sytem.IO.Filestream". I''m not used to Silverlight but the examples I have seen you should use

object content = XamlReader.Load(fileStream.ReadToEnd());//



我希望这可以.



I hope this will work.


这篇关于非法的xml字符[行:1位置:2]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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