Need a regular expression to catch the everything nested in target tag.
<?xml version="1.0" encoding="utf-8"?>
<data>
<target>
"<x id="c400c8394f0a" pid="NLCaption" name="NLCaption" />Caption"
</target>
<target />
<target><x id="a1e6b03cb682" pid="NLSheets" name="NLSheets" />Sheets"</target>
</data>
Thanks to Brettz, Who helped me in writing the following regular expression
$pattern = "@<target(?:\s.*?)?>(.*?)</target\s*>@s";
This regular expression does the job and help me getting all the content. But the only problem is that it also catches the <target /> tag as well.
I wan to modify the regular expression that donot catches unpaired tag. i.e. <target />
Please help me