var outerElement := new XmlElement withName('outer');
var innerElement := new XmlElement withName('inner');
outerElement.Add(innerElement);
var text := new XmlText(innerElement);
text.Value := 'hello';
var document := XmlDocument.WithRootElement(outerElement);
var options := new XmlFormattingOptions;
options.NewLineForElements := true;
options.WriteNewLineAtEnd := true;
var doc := document.ToString(true,options);
NSLog('%@',doc);
document.SaveToFile('/Users/JohnMoshakis/Downloads/format.xml',options);
I get this
<outer><inner/></outer>
Whats the proper way to add xmltext ? Also why is there no formatting ?
Not sure what this is asking. whats the result you want, <inner>hello</inner>? if so, just set `innerElement.Value := “hello”.
as it stands, you’re never doing anything with the text object yu create (assigned from setting its value), so it wont show in the document, because its never added anywhere…
define “no formatting”? XmlFormattingOptions has a boatload off options for how you want to your XMNL to look (if there’s any concrete scenario you cant achieve, let me know).
the first was my preferred one, but a few years back Fire has switched to exclusively using the XmlStyleVisualStudio now, to avoid project file changes when switching IDEs.
i’l have to check with the team; it seems that this .ctor should probably not be public…
Possibly; the default is PreserveAllWhitespace which, as it says on the box, preserves all space exactly as it was read it on set up — and since (I assume) you’re not manually adding and whitespace via code this would mean there is no whitespace to emit…