开发者

Question about XmlReader.Read() method

I am confused about the XmlReader.Read() output. Hope someone could explain it.

It seems the XmlReader.Read() method alwa开发者_JS百科ys gives an extra blank line?

Below is my code:

    public static void TestXML()
    {
        XmlReader r = XmlReader.Create(@"d:\snapshot_skeleton.xml");

        //r.MoveToContent();
        while (r.Read())
        {
            Console.Write(new String('.', r.Depth));
            Console.WriteLine(r.Name);
        }
    }

Below is the output:

xml
    <-----------------what is this?
person
.   <-----------------what is this?
.name
..  <-----------------what is this?
.name
.
.gender
..
.gender
.
.age
..
.age
.
person


The empty lines are caused by text nodes, which don't have a Name.

See the table here. Immediately before it is explained:

All other node types return an empty string.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜