I want to use System.XML, so we can parse the xml document with XMLDocument class, but in xaml.cs I am not able to find XMLDocument, so how can I do that....
var products = from product in xmlProducts.Descendants("Product")
select new
{
ProductID = Convert.ToInt32(product.Element("ProductId").Value),
ProductName = (string)product.Element("ProductName").Value
};
(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)
Please see this post:
http://silverlight.net/forums/p/15888/52427.aspx#52427. Check out the Tim Heuer post I referred to in that thread. You will find a sample in that post that shows how you can access a web service from a Silverlight app.
lmenaria
Member
18 Points
48 Posts
How to use XMLDocument in Silverlight
Mar 15, 2008 06:37 AM | LINK
Hello,
I want to use System.XML, so we can parse the xml document with XMLDocument class, but in xaml.cs I am not able to find XMLDocument, so how can I do that....
Thanks
Laxmilal
mchlSync
Star
14968 Points
2799 Posts
Re: How to use XMLDocument in Silverlight
Mar 15, 2008 07:22 AM | LINK
You can use XDocument from LINQ. I used to use like that. It's pretty cool
XDocument xmlProducts = XDocument.Parse(xmlContent);
var products = from product in xmlProducts.Descendants("Product")
select new
{
ProductID = Convert.ToInt32(product.Element("ProductId").Value),
ProductName = (string)product.Element("ProductName").Value
};
Regards,
Michael Sync
Silverlight MVP
Blog : http://michaelsync.net
deepikaFO
Member
14 Points
7 Posts
Re: How to use XMLDocument in Silverlight
May 09, 2008 06:44 AM | LINK
Hi,
iam getting the xmlcontent,
but in the products iam not getting any values,
iam getting error like this: [EmptyEnumerable]
Arguments:
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=2.0.30226.2&File=System.Core.dll&Key=EmptyEnumerable
Can any one tell how to the xmlconent?
iam getting the string in xmlformat ,
it contains some nodes,
i want to get the value of the node into a arry ,
Can u please explaine how u read the product?
sladapter
All-Star
43609 Points
7910 Posts
Re: How to use XMLDocument in Silverlight
May 09, 2008 03:10 PM | LINK
Can you show your XML here?
Software Engineer
Aprimo, Inc
Please remember to mark the replies as answers if they answered your question
deepikaFO
Member
14 Points
7 Posts
Re: Re: How to use XMLDocument in Silverlight
May 10, 2008 10:57 AM | LINK
Thanks For Replying,
i solved that problem,
i have one more error:
An exception of type 'System.ServiceModel.ProtocolException' occurred in System.ServiceModel.dll but was not handled in user code
How to solve this?
when isearched i got ans as add "clientaccesspolicy.xml" in the root domain.
this one iam not getting how to add?
i have one "silverlight Applciation"
one "Web service"
after calling web service in silverlgith application and run iam getting this error.
Please Reply me ASAP.
Thanks & Reagards
Deepika
lmenaria
Member
18 Points
48 Posts
Re: Re: Re: How to use XMLDocument in Silverlight
May 10, 2008 12:37 PM | LINK
Deepika,
Try this http://silverlight.net/forums/p/12495/41047.aspx
Thanks
deepikaFO
Member
14 Points
7 Posts
Re: Re: Re: How to use XMLDocument in Silverlight
May 12, 2008 05:52 AM | LINK
Hi,
i have seen that http://silverlight.net/forums/p/12495/41047.aspx.
But iam not understanding properly what to do?
Can any one gives me steps how to access Webservice from silverlgiht application?
Thanks
Deepika
Jim Mangaly
Contributor
2646 Points
383 Posts
Re: Re: Re: How to use XMLDocument in Silverlight
May 12, 2008 06:04 AM | LINK
Please see this post: http://silverlight.net/forums/p/15888/52427.aspx#52427. Check out the Tim Heuer post I referred to in that thread. You will find a sample in that post that shows how you can access a web service from a Silverlight app.
Hope this helps,
Jim (http://jimmangaly.blogspot.com/)
Please MARK the replies as answers if they answered your question
deepikaggupta
Member
8 Points
8 Posts
How to use XMLDocument in Silverlight
May 28, 2008 06:35 AM | LINK
hi i am facing the same problem.
XDocument xmldivisions = XDocument.Parse(xmlContent); var divs = from div in xmldivisions.Descendants("div1") select new Division{
id = (int)div.Attribute("id"),image = (string)div.Element("span").Element("img").Attribute("src").Value};
My XML file is:
<?xml version="1.0" encoding="utf-8" ?><
div1 id="slides"> <div id="slide1" class="mymsn-child mymsn-first cf"><
span class="imgmap"><
img usemap="#smap1" src="http://stb.msn.com/i/EB/34889C9F901EDB2E9D32673B0F036.jpg" width="365" height="170" alt="History of Memorial Day // Photo illustration of American casualty of war (© History.com; Jill Fromer/Getty Images)" /> </span></
div> <div id="slide2" class="child"><
span class="imgmap"><
img usemap="#smap2" src="http://stb.msn.com/i/BD/1AEFC69750E3F73244FF62D8286EAD.jpg" width="365" height="170" alt="Tony Hawk's Extreme Gadgets // Photo illustration of Tony Hawk & tech gadgets (© Tony Hawk; T-Mobile; Apple; Panasonic)" /></span>
</div>
</div>
in xmlcontent it is giving XMl data but i am not getting anything in id and image.
Please let me know what's the problem and possible solution.
mchlSync
Star
14968 Points
2799 Posts
Re: How to use XMLDocument in Silverlight
May 28, 2008 06:43 AM | LINK
I think it should be "div" not div1.
Regards,
Michael Sync
Silverlight MVP
Blog : http://michaelsync.net