How to parse a structured (XML Like) texts in JavaScript?

I have a text data with nested format, like an XML format but is using brackets {} instead of <>. What would be the best way to parse this, maybe convert it to XML format? I will then manipulate it like display it on a page or save the info on data base.

This is how it looks like:

{myItem num="345"}
{subItem num="1"}
My Sub item Texts
{/subItem}
{subItem num="2"}
My Sub item Texts
{/subItem}
{/myItem}

As you can see, it looks like an XML format but it uses brackets.

6 thoughts on “How to parse a structured (XML Like) texts in JavaScript?”

Leave a Comment