# XML EDITOR

**URL:** https://forum.alternetsoft.com/t/xml-editor/27
**Category:** AlterNET Studio Support
**Tags:** editor
**Created:** [November 15, 2017, 12:00am UTC](https://forum.alternetsoft.com/t/xml-editor/27 "2017-11-15T00:00:00Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![abhi.singhal](https://forum.alternetsoft.com/letter_avatar_proxy/v4/letter/a/606060/32.png) [@abhi.singhal](https://forum.alternetsoft.com/u/abhi.singhal)
#### Post date: [November 15, 2017, 12:00am UTC](https://forum.alternetsoft.com/t/xml-editor/27/1 "2017-11-15T00:00:00Z")

</div>

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

---

<div class="post-metadata">

### Author: ![andrew.medvedev](https://forum.alternetsoft.com/user_avatar/forum.alternetsoft.com/andrew.medvedev/32/28_2.png) [@andrew.medvedev](https://forum.alternetsoft.com/u/andrew.medvedev)
#### Post date: [November 15, 2017, 12:00am UTC](https://forum.alternetsoft.com/t/xml-editor/27/2 "2017-11-15T00:00:00Z")

</div>

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

---

<div class="post-metadata">

### Author: ![abhi.singhal](https://forum.alternetsoft.com/letter_avatar_proxy/v4/letter/a/606060/32.png) [@abhi.singhal](https://forum.alternetsoft.com/u/abhi.singhal)
#### Post date: [November 16, 2017, 12:00am UTC](https://forum.alternetsoft.com/t/xml-editor/27/3 "2017-11-16T00:00:00Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![andrew.medvedev](https://forum.alternetsoft.com/user_avatar/forum.alternetsoft.com/andrew.medvedev/32/28_2.png) [@andrew.medvedev](https://forum.alternetsoft.com/u/andrew.medvedev)
#### Post date: [November 16, 2017, 12:00am UTC](https://forum.alternetsoft.com/t/xml-editor/27/4 "2017-11-16T00:00:00Z")

</div>

Hi,  
yes these are possible.  
Please have a look at this demo:  
[https://www.alternetsoft.com/projects/XmlDemo.zip](https://www.alternetsoft.com/projects/XmlDemo.zip)  
You can use "Ctrl+K+D" key combination to smart format document.  
regards,  
Andrew

---

<div class="post-metadata">

### Author: ![wknauf](https://forum.alternetsoft.com/letter_avatar_proxy/v4/letter/w/606060/32.png) [@wknauf](https://forum.alternetsoft.com/u/wknauf)
#### Post date: [January 26, 2021, 12:00am UTC](https://forum.alternetsoft.com/t/xml-editor/27/5 "2021-01-26T00:00:00Z")

</div>

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

---

<div class="post-metadata">

### Author: ![andrew.medvedev](https://forum.alternetsoft.com/user_avatar/forum.alternetsoft.com/andrew.medvedev/32/28_2.png) [@andrew.medvedev](https://forum.alternetsoft.com/u/andrew.medvedev)
#### Post date: [January 29, 2021, 12:00am UTC](https://forum.alternetsoft.com/t/xml-editor/27/6 "2021-01-29T00:00:00Z")

</div>

Hi Wolfgang,  
   
Thank you for the suggestions.  
I've uploaded modified sample here:   
[https://www.alternetsoft.com/projects/XmlDemo\_v7.zip](https://www.alternetsoft.com/projects/XmlDemo_v7.zip)  
Please try it and let me know whether it works as expected.  
Regards,  
Andrew

---

<div class="post-metadata">

### Author: ![wknauf](https://forum.alternetsoft.com/letter_avatar_proxy/v4/letter/w/606060/32.png) [@wknauf](https://forum.alternetsoft.com/u/wknauf)
#### Post date: [January 30, 2021, 12:00am UTC](https://forum.alternetsoft.com/t/xml-editor/27/7 "2021-01-30T00:00:00Z")

</div>

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

---

<div class="post-metadata">

### Author: ![andrew.medvedev](https://forum.alternetsoft.com/user_avatar/forum.alternetsoft.com/andrew.medvedev/32/28_2.png) [@andrew.medvedev](https://forum.alternetsoft.com/u/andrew.medvedev)
#### Post date: [February 18, 2021, 12:00am UTC](https://forum.alternetsoft.com/t/xml-editor/27/8 "2021-02-18T00:00:00Z")

</div>

Hi Wolfgang,  
   
Sorry for delay in reply.  
I've uploaded modified sample here:   
[https://www.alternetsoft.com/projects/XmlDemo\_02182021.zip](https://www.alternetsoft.com/projects/XmlDemo_02182021.zip)  
Please try it and let me know whether it works as expected.  
Regards,  
Andrew

---

<div class="post-metadata">

### Author: ![wknauf](https://forum.alternetsoft.com/letter_avatar_proxy/v4/letter/w/606060/32.png) [@wknauf](https://forum.alternetsoft.com/u/wknauf)
#### Post date: [February 20, 2021, 12:00am UTC](https://forum.alternetsoft.com/t/xml-editor/27/9 "2021-02-20T00:00:00Z")

</div>

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
