Чтение XML под Silverlight...

??????? ???????? ?????? XML ??? Silverlight. ???????? ??? ???? ? Webdata (??????, ??????? ??????? MSXML & System.Xml) ?, ??????? ??, ?????? ????? ????????? ? XPathNavigator... ???, ??? ??, ???????? ????... ?????????, Silverlight - ??? ???????????? .Net. ????? ??????????? ??? XPathNavigator ? ??? ?? ??????. ? ?????, ? ?????? XPathNavigator? ?? ????? ??????. ???? ? ???, ??? ??, ??? ?????? ???????? DOM ?? ????? ??????? ? ????, ??? ????? ???????? XPath (??? ??????????? ? ??????? ???????, ??????????? ?? ??? ???????? ?? ?? Microsoft, ? ?? ?????? ?????? ?????), ??????? ???????????????? ????? XPath ?? DOM ?? ?????? ???????, ? ?????? ??????????????. ?????? ? ?????? ??????? ??? ?????????????. ???? ? ???, ??? ? ???, ? ?????? ????????? ???????????? ????????? ????????? ??????. ?, ???, ??? ???????????? ?????? ??????, ??? ??? ?????????? ?? ?? ???? ????????????? ???? ? ??????, ??? ??????.

??????? ? ??? ???????? XPathNavigator, ??? ????? ?? ?? ????? ??? ? DOM, ?? ?? ????????? ????? DOM ?????????, ???? ????????? ????????? ?????? XPath, ? ?????? ??????????? ??????? ??? ????????????? XPath.

??, ?????, ??? XPathNavigator ? ?? ????, ????????? ??????? DOM, ?? ???? XmlDocument. ???! ??? ???? ???...

????? System.Xml.Linq? ????? ?? ????... ??? ?????? reference ???????? ? ??? ????? ?? ?????????????... ?????????????, ?? ?? ???????????. Linq - ??? ?? ?????? ??????????? ????? ? Silverlight, ????? ? ?? ???? ?? ?????.

??? ??? ?? ???????? ??????? ????????????? ???. XmlReader. ??????? ??, ?? ?????. ???? ?????. ????????? ??????????????????.

????, ????? ? ??? ???? XML ?????:

<

rootElem>
<elem1 attr1="1" attr2="a">
</elem1>
<elem2 attr="q"/>
<elem3 attr3="eee">
                    Some random text to show access to element content
          </elem3>
</rootElem>

??? ??? ?????? ??? ?????? XmlReader? ? ??????. 

using

System;
using System.IO;
using System.Xml;

namespace

XmlReaderTest
{
     class Program
     {
          static void Main(string[] args)
{
               FileStream fs = new FileStream("test.xml", FileMode.Open, FileAccess.Read);
               XmlReader rd = XmlReader.Create(fs);
               bool attr3flag = false;
               while (rd.Read())
{
                    if (rd.Name.Equals("rootElem"))
{
                         if (rd.IsStartElement())
{
                              Console.WriteLine("Beginning of the document");
}
                         else
                         {
                              Console.WriteLine("End of the document");
}
}
                    else if (rd.IsStartElement("elem1"))
{
                         Console.WriteLine("Attribute 1 of elem1 is {0} and attribute 2 of it is {1}",
rd.GetAttribute("attr1"), rd.GetAttribute("attr2"));
}
                    else if (rd.IsStartElement("elem2"))
{
                         Console.WriteLine("Attribute of elem2 is {0}", rd.GetAttribute("attr"));
}
                    else if (rd.IsStartElement("elem3"))
{
                         Console.WriteLine("Attribute of elem3 is {0}", rd.GetAttribute("attr3"));
attr3flag = true;
}
                    else if (rd.NodeType == XmlNodeType.Text && attr3flag)
{
attr3flag = false;
                         Console.WriteLine("Text of elem3 is {0}", rd.Value);
}
}
fs.Close();
}
}
}

? ?????, ????? ???????? ????? ???????? ? ?????????, ????????? rd.ReadToDescendant()

? ??????-?? XmlReader ?? ????? ?????, ?? ? ???????????? ????? ??????, ??????. ???? ?????.

---

????????? 3.24.08: ??????, ????????? ? ???????, Linq, ??????, ???-???? ????????, ???? ?? ?????? ????? ??????? ????????? ?????? ?????? ??????????. ???????, ??????? ????? ? ????????? ??.