Horje
string to xml c# Code Example
string to xml c#
string test = "<body><head>test header</head></body>";

XmlDocument xmltest = new XmlDocument();
xmltest.LoadXml(test);

XmlNodeList elemlist = xmltest.GetElementsByTagName("head");

string result = elemlist[0].InnerXml; 

//result -> "test header"
c# parse string to xml
/*
<Names>
    <Name>
        <FirstName>John</FirstName>
        <LastName>Smith</LastName>
    </Name>
    <Name>
        <FirstName>James</FirstName>
        <LastName>White</LastName>
    </Name>
</Names>
*/

XmlDocument xml = new XmlDocument();
xml.LoadXml(myXmlString); // suppose that myXmlString contains "<Names>...</Names>"

XmlNodeList xnList = xml.SelectNodes("/Names/Name");
foreach (XmlNode xn in xnList)
{
  string firstName = xn["FirstName"].InnerText;
  string lastName = xn["LastName"].InnerText;
  Console.WriteLine("Name: {0} {1}", firstName, lastName);
}




Csharp

Related
string interpolation in C# Code Example string interpolation in C# Code Example
How do i destroy a prefab without the error? Code Example How do i destroy a prefab without the error? Code Example
c# how to refresh your binding source Code Example c# how to refresh your binding source Code Example
how to configure session timeout in asp.net core Code Example how to configure session timeout in asp.net core Code Example
c# how to refreshyour bindingsource Code Example c# how to refreshyour bindingsource Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10