Skip to main content

Microsoft Silverlight

Answered Question How to use XMLDocument in SilverlightRSS Feed

(0)

lmenaria
lmenaria

Member

Member

16 points

19 Posts

How to use XMLDocument in Silverlight

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
mchlsync

Star

Star

14606 points

2,730 Posts

Silverlight MVP
Answered Question

Re: How to use XMLDocument in Silverlight

 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
                                   };

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Regards,
Michael Sync
Silverlight MVP

Blog : http://michaelsync.net


deepikaFO
deepikaFO

Member

Member

14 points

7 Posts

Re: How to use XMLDocument in Silverlight

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
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Re: How to use XMLDocument in Silverlight

Can you show your XML here?

 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

deepikaFO
deepikaFO

Member

Member

14 points

7 Posts

Re: Re: How to use XMLDocument in Silverlight

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
lmenaria

Member

Member

16 points

19 Posts

Re: Re: Re: How to use XMLDocument in Silverlight

Deepika,

Try this http://silverlight.net/forums/p/12495/41047.aspx

Thanks
 

deepikaFO
deepikaFO

Member

Member

14 points

7 Posts

Re: Re: Re: How to use XMLDocument in Silverlight

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
Jim Mangaly

Contributor

Contributor

2622 points

381 Posts

Re: Re: Re: How to use XMLDocument in Silverlight

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

http://www.identitymine.com/

deepikaggupta
deepikag...

Member

Member

8 points

8 Posts

How to use XMLDocument in Silverlight

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 &amp; 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
mchlsync

Star

Star

14606 points

2,730 Posts

Silverlight MVP

Re: How to use XMLDocument in Silverlight

deepikaggupta:
var divs = from div in xmldivisions.Descendants("div1")

 
I think it should be "div"  not div1.

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Regards,
Michael Sync
Silverlight MVP

Blog : http://michaelsync.net


deepikaggupta
deepikag...

Member

Member

8 points

8 Posts

Re: How to use XMLDocument in Silverlight

I tried that too but it still not working...... :(

i actully want the image source and want to display that iamge in one rectangle....how can i do it....

Bichitra
Bichitra

Member

Member

3 points

39 Posts

Re: How to use XMLDocument in Silverlight

Hi,

 

I have the same problem.  I have a method  GetXmlDocument() which return XlDocument object.

I am not able to get XmlDocument Class in my silverlight project. Any body can help me. how to use.

( I have xml config file inside  WebProject file , I want to write a service which return the xmldocument object and i want to parse the document in silverlight application), 

 

Thanks

Bichitra

 

 

bichitra kumar pattanayak

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Re: How to use XMLDocument in Silverlight

Silverlight does not support old XMLDocument/XMLEelement/XMLAttribute classes which are in .Net System.XML namespace.

However, you can use XDocument/XElement/XAttribute classes which are in System.Xml.Linq namesapce.

 

 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

RockRake
RockRake

Member

Member

14 points

2 Posts

Re: How to use XMLDocument in Silverlight

string value = "<Drawable><Objects><Item>1</Item></Objects><Objects><Item>2</Item></Objects><Objects><Item>3</Item> </Objects></Drawable>"

XDocument xd = XDocument.Parse(value);

 

var drawables = from dra in xd.Descendants("Drawable")

select dra;

foreach (var draw in drawables)

{

var objects = from obj in xd.Descendants("Objects")

select obj;

foreach (var obj in objects)

{

}

}

 

i think it work properly

Rakesh(rockRake)

Anjusoft

juliako
juliako

Member

Member

28 points

14 Posts

Re: How to use XMLDocument in Silverlight

Hi, you might find the following documentation helpful: http://msdn.microsoft.com/en-us/library/cc188996(VS.95).aspx.

I am the programming writer on the .Net Framework and Silverlight .Net Framework Managed XML team. If

you have questions, you can send me an email at juliako@microsoft.com.

Thank you,

Julia

Julia Kornich [MSFT]
This posting is provided "AS IS" with no warranties, and confers no rights.
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities