!要么 。 (感叹号或点)首先在xml读取时出现。 [英] ! or . (exclamation mark or dot) comes out first on xml read.

查看:275
本文介绍了!要么 。 (感叹号或点)首先在xml读取时出现。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


所以这对我来说是一个奇怪的问题。


我有一个代码可以读取xml文件并打印输出。但总是在第一次读取我的字符串,如果使用!要么 。 ,它首先输出它们而不是它们在xml文件中。


示例:

< prints> 
< Id> 1< / Id>
< comment>哦是啊!!!!< / comment>
< / prints>

请参阅以下代码阅读:

 var xmlDB =(来自仓库中的i.Root.Descendants(" prints"))其中Int32.Parse(i.Element(" Id")。Value)> 0选择i); 

foreach(XElement打印在xmlDB.OrderByDescending(x => int.Parse(x.Element(" Id")。。Value)))
{
运行printxml = new Run();
printxml.Text = prints.Element(" comment")。Value + Environment.NewLine;
printxml.FontSize = 20;

commentTextBlock.Inlines.Add(printxml);

所以在我的xml文件中它是okey和!要么 。是最后写的,但它显示了!在读取字符串之前。


AND。请注意,这仅适用于第一个条目!如果我在我的xml文件中创建一个新条目(比如id 2),它将在xaml页面上正确读出。

解决方案

< prints> 
< Id> 1< / Id>
< comment><![CDATA [oh yeah !!!!]]< / comment>
< / prints>

在xml中尝试这个



Hello,

so this is a strange issue for me.

I have a code that reads an xml file and prints the output. But always on the first read my string, if using ! or . , it prints out them first instead of as they are in the xml file.

Example:

  <prints>
    <Id>1</Id>
    <comment>oh yeah!!!!</comment>
  </prints>

See below code for the read:

      var xmlDB = (from i in warehouse.Root.Descendants("prints") where Int32.Parse(i.Element("Id").Value) > 0 select i);

                foreach (XElement prints in xmlDB.OrderByDescending(x => int.Parse(x.Element("Id").Value)))
                {
                    Run printxml = new Run();
                    printxml.Text = prints.Element("comment").Value + Environment.NewLine;
                    printxml.FontSize = 20;

                    commentTextBlock.Inlines.Add(printxml);

So in my xml-file it's okey and the ! or . is written last but it displays the ! Before the string on read.

AND, also. Note that this ONLY applies at the first entry! If I make a new entry (let's say id 2) in my xml file it will read it out correctly on the xaml-page.

解决方案

  <prints>
    <Id>1</Id>
    <comment><![CDATA[oh yeah!!!!]]</comment>
  </prints>

Try this in the xml


这篇关于!要么 。 (感叹号或点)首先在xml读取时出现。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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