Parsing note-tag with nested tags

So I've got this kind of note-tag:

<tagName> type: skill id: 2 <condition> some formula on multiple lines </condition> forced: true</tagName>"condition" is a nested tag.My note-tag format will have at most one-level of nesting (so you won't have tags nested within tags)

But I'm not sure how to parse the body of the tag.

I use this expression to find valid tags:

/<tagName>(.*?)<\/tagName>/imBut now when it comes time to parse the body, how would that be done?If it was just

Code:
<tagName>type: skillid: 2forced: true</tagName>
I would just split on new-lines and then iterate over each line, but this approach doesn't really work when I introduce more a more complicated structure.
If RGSSx were 1.9 based, it would include rexml which is pretty easy to use.  I wrote an entire XML config file parser which worked great, until I found 'require rexml/document' did not work in RPG maker.

Is it possible to use "gem", the Ruby package system, within RPG Maker?  If it is, there is a nice package called xml-simple which would do nicely.

I'm just starting to learn Ruby myself.

You would probably have to create a set of classes, each of which represents a single XML document.  So you'd have to roll your own, which is doable but can get rather involved.
For this example

<tagName>  type: skill  id: 2  <condition>    some formula    on multiple lines  </condition>  forced: true</tagName>
1:

I suggest that you first extract the contents with the regular expression you gave

  type: skill  id: 2  <condition>    some formula    on multiple lines  </condition>  forced: true
2:

Extract the nested condition where you also substitute it with nothing. I.e. matched information put in another variable:

  <condition>    some formula    on multiple lines  </condition>Modified string:

  type: skill  id: 2  forced: trueYou can continue from here.

P.s. as your structure have the whiff of XML let me tell you that XML cannot properly be captured in regular expressions and trying to parse XML in the general case based on regular expression is folly.

*hugs*

Original thread: https://forums.rpgmakerweb.com/threads/parsing-note-tag-with-nested-tags.25557/