I'm building a website which has a textarea where it displays a chunk of XML code and allows user to edit it. It will be like below:
<textarea>
<person>
<name>AAA</name>
<position>Manager</position>
<age>40</age>
</person>
<person>
<name>BBB</name>
<position>CEO</position>
<age>50</age>
</person>
</textarea>
So basically the user will see a text box with the below XML code that he can edit:
<person>
<name>AAA</name>
<position>Manager</position>
<age>40</age>
</person>
<person>
<name>BBB</name>
<position>CEO</position>
<age>50</age>
</person>
Of course by default they will show as plain, black text. My goal is to
1) Highlight the xml tags (same as what StackOverflow shows) so that it's easier for the user to read the xml content
2) When the user edits the xml content, the content is dynamically highlighted again
Is there any JavaScript that's ready out there and will help me do this?
Thanks a lot!
Aucun commentaire:
Enregistrer un commentaire