I use Linq To XML to create XML that is sent to a third party. I find it difficult to understand how to create XML using Linq when some of the information I want to send to XML is dynamic.
The dynamic part of XML is stored as an array [,]. This multidimensional array contains 2 values.
I can "build" dynamic XML up using a string constructor and store the values โโthat were in the array in a string variable, but when I try to include this variable in Linq, the variable is HTMLEncoded, and not included as proper XML.
How do I add an add to a dynamically built string for XML generated by Linq?
Example:
//string below contains values passed into my class
string [,] AccessoriesSelected;
//I loop through the above array and build up my 'Tag' and store in string called AccessoriesXML
//simple linq to xml example with my AccessoriesXML value passed into it
XDocument RequestDoc = new XDocument(
new XElement("MainTag",
new XAttribute("Innervalue", "2")
),
AccessoriesXML);
"" , XML , , - , .
, , :
<MainTag> blah blah </MainTag>
< ;Tag> ;< ;InnerTag> ; option1="valuefromarray0" option2="valuefromarray1" /> ;< ;Tag/> ;
- :
<MainTag> blah blah </MainTag>
<Tag><InnerTag option1="valuefromarray0" option2="valuefromarray1" /></Tag>
<Tag><InnerTag option1="valuefromarray0" option2="valuefromarray1" /></Tag>
? XmlDocument, , Linq, .
,