문제

I am currently writing a C# script to create an XML file based on a sample I have been given and typically I add an element like so:

node.Add(new XElement("NodeName", new XCData("Value")));

However on the XML sample it uses the following before the CDATA to create a space in the finished document (as transformed in html later):

  // The XML is like:
<NodeName>&#160;&#160;<!CDATA[Value]]></NodeName>

I have tried to add spaces before the value in the XCData declaration but it always ignores them, is there some way I can either add the same as the XML, preserve any spaces I put in or perhaps tab before the value?

도움이 되었습니까?

해결책

To add a few spaces:

 node.Add(new XElement("NodeName", "  ", new XCData("Value")));
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top