[已解决问题]
解决于 2008-08-06 13:58
<P>我创建了一个xml文件,然后用XmlReader进行读取。但出现了一些问题,调试不出来。大侠帮帮忙。具体情况如下</P>
<P>xml格式:</P>
<DIV class=e><SPAN class=b><STRONG><FONT color=#ff0000> </FONT></STRONG></SPAN> <FONT color=#0000ff><SPAN class=m><?</SPAN><SPAN class=pi>xml version="1.0" encoding="gb2312" </SPAN><SPAN class=m>?></SPAN></FONT> </DIV>
<DIV class=e>
<DIV class=c style="MARGIN-LEFT: 1em; TEXT-INDENT: -2em"><A class=b onfocus=h() onclick="return false" href="file:///K:/Project/NET/SEC/SEC/bin/Debug/Data/Favorites.xml#"><STRONG><FONT color=#ff0000>-</FONT></STRONG></A> <SPAN class=m><FONT color=#0000ff><</FONT></SPAN><SPAN class=t><FONT color=#990000>Favorites</FONT></SPAN><SPAN class=m><FONT color=#0000ff>></FONT></SPAN></DIV>
<DIV>
<DIV class=e>
<DIV class=c style="MARGIN-LEFT: 1em; TEXT-INDENT: -2em"><A class=b onfocus=h() onclick="return false" href="file:///K:/Project/NET/SEC/SEC/bin/Debug/Data/Favorites.xml#"><STRONG><FONT color=#ff0000>-</FONT></STRONG></A> <SPAN class=m><FONT color=#0000ff><</FONT></SPAN><FONT color=#990000><SPAN class=t>Folder</SPAN><SPAN class=t> Name</SPAN></FONT><SPAN class=m><FONT color=#0000ff>="</FONT></SPAN><B>搜索</B><FONT color=#0000ff><SPAN class=m>"</SPAN><SPAN class=m>></SPAN></FONT></DIV>
<DIV>
<DIV class=e>
<DIV style="MARGIN-LEFT: 1em; TEXT-INDENT: -2em"><SPAN class=b><STRONG><FONT color=#ff0000> </FONT></STRONG></SPAN> <SPAN class=m><FONT color=#0000ff><</FONT></SPAN><SPAN class=t><FONT color=#990000>Title</FONT></SPAN><SPAN class=m><FONT color=#0000ff>></FONT></SPAN><SPAN class=tx><STRONG>百度</STRONG></SPAN><SPAN class=m><FONT color=#0000ff></</FONT></SPAN><SPAN class=t><FONT color=#990000>Title</FONT></SPAN><SPAN class=m><FONT color=#0000ff>></FONT></SPAN> </DIV></DIV>
<DIV class=e>
<DIV style="MARGIN-LEFT: 1em; TEXT-INDENT: -2em"><SPAN class=b><STRONG><FONT color=#ff0000> </FONT></STRONG></SPAN> <SPAN class=m><FONT color=#0000ff><</FONT></SPAN><SPAN class=t><FONT color=#990000>Url</FONT></SPAN><SPAN class=m><FONT color=#0000ff>></FONT></SPAN><SPAN class=tx><STRONG>http://www.baidu.com</STRONG></SPAN><SPAN class=m><FONT color=#0000ff></</FONT></SPAN><SPAN class=t><FONT color=#990000>Url</FONT></SPAN><SPAN class=m><FONT color=#0000ff>></FONT></SPAN> </DIV></DIV>
<DIV><SPAN class=b><STRONG><FONT color=#ff0000> </FONT></STRONG></SPAN> <SPAN class=m><FONT color=#0000ff></</FONT></SPAN><SPAN class=t><FONT color=#990000>Folder</FONT></SPAN><SPAN class=m><FONT color=#0000ff>></FONT></SPAN></DIV></DIV></DIV>
<DIV class=e>
<DIV class=c style="MARGIN-LEFT: 1em; TEXT-INDENT: -2em"><A class=b onfocus=h() onclick="return false" href="file:///K:/Project/NET/SEC/SEC/bin/Debug/Data/Favorites.xml#"><STRONG><FONT color=#ff0000>-</FONT></STRONG></A> <SPAN class=m><FONT color=#0000ff><</FONT></SPAN><FONT color=#990000><SPAN class=t>Folder</SPAN><SPAN class=t> Name</SPAN></FONT><SPAN class=m><FONT color=#0000ff>="</FONT></SPAN><B>娱乐</B><FONT color=#0000ff><SPAN class=m>"</SPAN><SPAN class=m>></SPAN></FONT></DIV>
<DIV>
<DIV class=e>
<DIV style="MARGIN-LEFT: 1em; TEXT-INDENT: -2em"><SPAN class=b><STRONG><FONT color=#ff0000> </FONT></STRONG></SPAN> <SPAN class=m><FONT color=#0000ff><</FONT></SPAN><SPAN class=t><FONT color=#990000>Title</FONT></SPAN><SPAN class=m><FONT color=#0000ff>></FONT></SPAN><SPAN class=tx><STRONG>搜狐</STRONG></SPAN><SPAN class=m><FONT color=#0000ff></</FONT></SPAN><SPAN class=t><FONT color=#990000>Title</FONT></SPAN><SPAN class=m><FONT color=#0000ff>></FONT></SPAN> </DIV></DIV>
<DIV class=e>
<DIV style="MARGIN-LEFT: 1em; TEXT-INDENT: -2em"><SPAN class=b><STRONG><FONT color=#ff0000> </FONT></STRONG></SPAN> <SPAN class=m><FONT color=#0000ff><</FONT></SPAN><SPAN class=t><FONT color=#990000>Url</FONT></SPAN><SPAN class=m><FONT color=#0000ff>></FONT></SPAN><SPAN class=tx><STRONG>http://www.sohu.com</STRONG></SPAN><SPAN class=m><FONT color=#0000ff></</FONT></SPAN><SPAN class=t><FONT color=#990000>Url</FONT></SPAN><SPAN class=m><FONT color=#0000ff>></FONT></SPAN> </DIV></DIV>
<DIV><SPAN class=b><STRONG><FONT color=#ff0000> </FONT></STRONG></SPAN> <SPAN class=m><FONT color=#0000ff></</FONT></SPAN><SPAN class=t><FONT color=#990000>Folder</FONT></SPAN><SPAN class=m><FONT color=#0000ff>></FONT></SPAN></DIV></DIV></DIV>
<DIV><SPAN class=b><STRONG><FONT color=#ff0000> </FONT></STRONG></SPAN> <SPAN class=m><FONT color=#0000ff></</FONT></SPAN><SPAN class=t><FONT color=#990000>Favorites</FONT></SPAN><SPAN class=m><FONT color=#0000ff>></FONT></SPAN></DIV>
<DIV><SPAN class=m><FONT color=#0000ff>然后我读取所有Folder中的属性Name的值,将这些值保存至string[]当中。但我现在只能取到第一个Name和对应的值。</FONT></SPAN></DIV>
<DIV><SPAN class=m><FONT color=#0000ff>我的代码是这样的:</FONT></SPAN></DIV><SPAN class=m>
<DIV><BR> XmlReaderSettings settings = new XmlReaderSettings();<BR> settings.ConformanceLevel = ConformanceLevel.Fragment;<BR> settings.IgnoreWhitespace = true;<BR> settings.IgnoreComments = true;</DIV>
<DIV> this.reader = XmlReader.Create(file, settings);</DIV>
<DIV><BR> string folders = "";<BR> this.reader.ReadToFollowing("Folder");<BR> if (this.reader.HasAttributes)<BR> {<BR> while (reader.MoveToNextAttribute())<BR> {<BR> folders += this.reader.Name + ":" + this.reader.Value + ";";<BR> }<BR> }</DIV>
<DIV> </DIV>
<DIV>各位。告诉我怎么实现啊。谢谢了!</SPAN></DIV></DIV></DIV>
少之
|
菜鸟二级
|
园豆:
205
提问于:2008-08-06 12:46