XML field with different structure

Hello,

I have a problem when I try to accces elements of a XML file.

I need a way to extract the values for “start”, “end” and “level”, but the syntax is different.
xml

Thanks in advance!

Hi @darie.leolea

You can try with regex Expression

System.Text.RegularExpressions.Regex.Match(YourString,"(?<=start\D+)\d+").ToString

Output -> 2004
System.Text.RegularExpressions.Regex.Match(YourString,"(?<=end\D+)\d+").ToString

Output -> 2008
System.Text.RegularExpressions.Regex.Match(YourString,"(?<=level\D+)\d+").ToString

Output -> 5

image

Regards
Gokul

Another way to get the extracted data using Regex @darie.leolea

System.Text.RegularExpressions.Regex.Matches(YourString,"(?<!\s\D)\d+",System.Text.RegularExpressions.RegexOptions.Multiline)

image

Regards
Gokul

Hi,

Can you share your xml as a file?

Regards,

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.