Extract strings between one repeated tag in a XML file
Show older comments
Hi
I came across this XML file which looks like this:
...
<names id="10" name="Name1" type="one">
<subname id="7" name="subname1"/>
<proname id="70" name="proname1"/>
<proname id="6" name="proname40"/>
</names>
<names id="28" name="Name2" type="three">
<subname id="69" name="subname17"/>
<subname id="41" name="subname62"/>
<subname id="72" name="subname2"/>
<proname id="66" name="proname4"/>
</names>
...
My question is: how can I extract the strings between id="\d*" name="Name1 and </names given that I use names (Name1, Name2,...) to extract the related information (subname and proname)?
I have tried the following expression, but it didn't work out and I don't know why!
regexp(Dat,'(?<=names id="\d+" name="Name1").*(?=<\/names>)','match')
I appreciate any help in advance.
Accepted Answer
More Answers (0)
Categories
Find more on Structured Data and XML Documents in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!