Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Words inside xml tags

Status
Not open for further replies.

kaptlid

Technical User
Nov 26, 2006
86
US
I was given some non validating huge xml files to work with.
I need to print the words enclosed between certain tags.

Example: There are 25 instances of words inside <def> </def> tags in an xml file.

How do I output only the 25 words in between the tags?

The xml files are on average 3MB each in size.
And does anyone know a good website that explains regular expressions to a person who's never coded them? :)

Thanks,
 
website on regular expressions: regular-expressions.info

code

Code:
$pattern = '/<def>(.*?)<\/def>/ims';
preg_match_all($pattern, $xmlContent, $matches);
echo '<pre>';
print_r($matches);

the matches are contained in $matches[1] ... [n]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top