Closed viniciusfbb closed 1 year ago
It also fails on comments between XML nodes.
@viniciusfbb I just tested this and comments at the beginning of the file work just fine. I tried this test code:
procedure TTestXmlReader.TestIssue9_CommentsAtStart;
begin
var Doc := TXmlDocument.Create;
Doc.Parse('<!-- Comment at start of file -->'#10+
'<element>'#10+
'</element>');
var Root := Doc.Root;
{ <!-- Comment at start of file --> }
var Comment := Root.FirstChild;
Assert.AreEqual<TXmlNodeType>(TXmlNodeType.Comment, Comment.NodeType);
Assert.AreEqual<XmlString>(' Comment at start of file ', Comment.Value);
{ <element> }
var Element := Comment.NextSibling;
Assert.AreEqual<TXmlNodeType>(TXmlNodeType.Element, Element.NodeType);
Assert.AreEqual<XmlString>('element', Element.Value);
end;
Note that IXmlDocument
has both a Root
and DocumentElement
property. Look at the documentation of these properties for information on their differences.
The Root
property is like a virtual root. In this case, it has two children: the comment at the start of the file, and the <element>
element. The DocumentElement
property would return the <element>
element
Can you confirm if this works with the code you are using?
@luebbe In my testing, comments between XML elements works. Are you referring to the bug you mentioned in your pull request (https://github.com/neslib/Neslib.Xml/pull/8)? I just pushed a fixed for that.
@neslib I didn't debug it, but when I run GrijjyDeployMan in dprojs with comments at the beginning, like the one I sent, which is the same as the print below:
After saving, the following dproj is generated:
But when I run the same dproj without that comment, it works fine.
I posted the issue here because by logic it must be some limitation of Neslib.Xml.
That's not a Neslib.Xml limitation, but probably a bug in DeployMan. I'll look into that.
Ok. Thanks!
@viniciusfbb The actual error was inside the TXmlDocument.Save
method, so I fixed that.
I also updated the Neslib.Xml submodule inside the deployment manager, so you should update your local submodule of that repo as well.
@luebbe In my testing, comments between XML elements works. Are you referring to the bug you mentioned in your pull request (#8)? I just pushed a fixed for that.
Yes, that is the problem that I mentionend in pr #8. Thanks for the fix. I'll test it asap.
XML with comments at the beginning of the file is not supported, which is not uncommon. For example, GrijjyDeployMan cannot correctly read the Skia4Delphi .dprojs due to the comments at the beginning of the document: https://github.com/skia4delphi/skia4delphi/blob/main/Samples/Demo/FMX/Projects/RAD%20Studio%2011%20Alexandria/Skia4Delphi.dproj