Welton v3.62
Welton v3.62

Reputation: 2230

How do I load an XML formatted string into an XElement

I want to pass a varying number of parameters between two objects. I have a method on the receiving object that accepts a single string parameter. The sending object will be sending a string representation of an XElement.

Here is a sample string with one parameter specified:

<parameters><parameter Name="Code" Type="string" Value="007" /></parameters>

More parameters will be sent as additional <parameter> entries between the <parameters></parameters> tags.

What is the simplest way to load this string into an XElement?

And before we go down the just-send-the-XElement-to-the-receiver road, let me just say that there is COM in the middle, so I don't want to open that can of worms.

Upvotes: 2

Views: 1310

Answers (1)

Femaref
Femaref

Reputation: 61437

XElement x = XElement.Parse(xmlstring);

Upvotes: 2

Related Questions