Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Parsing XML
3 replies. Latest Post by Gamewolf on June 28, 2008.
(0)
Gamewolf
Member
89 points
72 Posts
06-27-2008 11:40 PM |
I am wanting to parse simple XML in Silverlight 2 Beta 2. I have searched google and the forums, but cannot find something simple. All I want is to have a simple xml file like this:
<node>
<node2>TextTextText</node2>
</node>
and in my Silverlight, a textblock will say whatever node2 is. I cannot find anything simple like this anywhere. Everything is always very complicated and whatnot. Anyone know how to do this? Thanks.
Leonid A...
632 points
135 Posts
06-28-2008 3:01 AM |
You can analyse text if it so simple:
sXML = "your xml";
if(sXML.Contains("<YourNodeName>"))
{
sData = sXML.Substring(sXML.IndexOf("<YourNodeName>") + "<YourNodeName>".Length, sXML.IndexOf("</YouNodeName>") - sXML.IndexOf("YourNodeName") - "YourNodeName".Length);
}
else //your data is null or string.Empty
sData = "";
robhouwe...
Contributor
3158 points
540 Posts
06-28-2008 3:21 AM |
This oneliner also does the trick (include System.Xml.Linq):
XElement
elem.ToString() returns the xml string.
(If this has answered your question, please click on mark as answer on this post)Cheers!Rob Houweling
06-28-2008 11:34 AM |
Ok, Thanks.