I am trying to convert an XML to JSON without using python package. To do so I am converting the XML to a list which will be eventually converted to a nested dictionary and then to JSON. I am unable to distinguish the following elements while reading the XML from a list :
<Description>TestData</Description>\nData</Description>\n<Description>Test\n
The regex I am using to distinguish 1 and 3 are :
x = re.compile("<Description>(.+?)<\/Description>\n")x = re.compile("^((?!Description).)*<\/Description>\\n")
I am finding it difficult to develop a regex for the THIRD one.
x = re.compile("\s*<Description>(.+)(?!((<\/Description>)))\n")
Although the second regex identifies the text 3 correctly it is also identifying the text 1. This should identify only text 3.