1
Answer

Parsing string to XElement throwing system.out of.memory

Alistair Cook

Alistair Cook

10y
1.1k
1

When I am trying to parse a string value which has a huge text, then I am getting system out of memory exception.

I am using below code.

foreach (KeyValuePair<string, object> item in newXMlValue)
{
      XElement node = (from c in orderXML.Descendants(item.Key) select c).FirstOrDefault();
      if (!object.Equals(node, null))
      {

            XElement xmlValue = XElement.Parse(item.Value.ToString()); // Here I am getting system out of // memory Exception

            node.ReplaceWith(xmlValue);
      }
}

 
Thanks 

Answers (1)