I have xml files formatted like this:
<User>
<FirstName>Foo Bar</FirstName>
<LastName>Blah</LastName>
<OtherStuff>...</OtherStuff>
<More>...</More>
<CompanyName>Foo</CompanyName>
<EmailAddress>bar@foo.com</EmailAddress>
</User>
<User>
...
I want to read through all xml files, creating as output <FirstName>,<CompanyName>,<EmailAddress>
, so:
Foo Bar,Foo,bar@foo.com
Name,User2,user@email.com
FSds,Blah,blah@blah.com
I am using the following regex
(?si)<FirstName>(.*?)</FirstName>.*?<CompanyName>(.*?)</CompanyName>\s*<EmailAddress>(.*?)</EmailAddress>'
However, this returns also everything from the tags between FirstName
and CompanyName
What am I doing wrong?