XML EDITOR

Hello
Can the code editor be used to edit generic XML files?
We are looking for automatic tag closing, error indication in case of invalid XML and node/attribute coloring.
Thanks
Abhishek
Hi,
Please try the following demo QuickStart Projects\Editor\Parsers\Advanced Syntax Parsing (you can run it from Demo Explorer), and select XML in the Language combobox.
It does provide coloring of tags and parameters, should be pretty easy to support underlining of invalid tags (i.e. if closing tag does not match open tag), please let me know if you need parser to catch any other errors as well.
Could yo also clarify how you expect automatic tag closing to work?
regards,
Andrew
Saw the sample - Coloring of tags and parameters looks good.
Current requirement is a basic one. So we need:
- Underlining of invalid tags (closing not matching opening)
- Automatic tag closing: As soon as a tag is typed, the closing tag is automatically inserted. Optionally, when a parameter is typed with a quotation mark, the closing quotation mark is automatically inserted.
- Pretty Print: The editor can convert any xml into properly formatted xml with cr/lf and indentation.
Hi,
yes these are possible.
Please have a look at this demo:
https://www.alternetsoft.com/projects/XmlDemo.zip
You can use "Ctrl+K+D" key combination to smart format document.
regards,
Andrew
Some things to improve in this sample:
a) if you enter an element which is not in the code completion popup, the typed text will be replaced by "<>>"
b) the code completion popup is not shown always when pressing "<" - but I cannot describe the necessary steps as it does not happen always. OI fixed the invalid XML before ;-).
c) code completion does not like empty elements: after typing "", an additional closing tag is appended.
Best regards
Wolfgang
Hi Wolfgang,

Thank you for the suggestions.
I've uploaded modified sample here:
https://www.alternetsoft.com/projects/XmlDemo_v7.zip
Please try it and let me know whether it works as expected.
Regards,
Andrew
Hi Andrew,
thanks for the fixes.
a) is fixed
b) I can reproduce it now: go to the end of the line with the "name" element, press "Enter".
In the new line, type "<". The code completion popup is shown. Wait until the error marker at the element "assembly" disappears.
Now press backspace to delete the "<" and type "<" again BEFORE the error marker is shown again. In this situation the popup is empty.
It works if the error marker is shown.

c) Works better now. But what about creating an empty element when typing "
d) (*NEW*) in the sample, the editor does not suggest/detect the closing "" element when typing "Best regards
Wolfgang
Hi Wolfgang,

Sorry for delay in reply.
I've uploaded modified sample here:
https://www.alternetsoft.com/projects/XmlDemo_02182021.zip
Please try it and let me know whether it works as expected.
Regards,
Andrew
Thanks, I can confirm that all is fixed.
I don't know whether I need all this work as I wait for an XSD parser (see other post). So probably this sample is not relevant for me. But hopefully my findings and your fixes help others ;-).

Best regards
Wolfgang