XDocument - Indentation formatting is removed when reading XML string for nodes that contain a child node that is text RRS feed

  • Question

  • Using XDocument to load an XML string, i noticed that while reading the string using

    XDocument DocumentRoot = XDocument.Parse(inputValue);

    A node that originally looks like this in the input string


    Ends up looking like this


    When I remove that text node


    The formatting is untouched, and it looks like it did before i parsed it

    But I need to preserve the indentation of the child nodes regardless of whether there is a text node or not.

    Why is it being modified automatically like that?

    • Edited by sjs1978 Monday, May 5, 2014 2:47 PM
    Monday, May 5, 2014 2:45 PM