good day, I have a UML class diagram exported to an XML file, and the code basically and repeatedly is like this:
<UML:Class name="Zip Code" isLeaf="false" xmi.id="{C7C65474-DD51-4165-89A0-FB552A929185}" isAbstract="false" visibility="public">
So, what i need to do, is to output to the user all the class(etc) found in the file. More exactly, i need to read the name inside the double quotes.
More properly, read the string inside the double quotes from a specific tag, example:
to get all classes names i must search in: <UML:Class name=" STRING WHAT I WANNA GET "
to get all atributtes names i must search in: <UML:Attribute name=" STRING I WANNA GET "
i have this code, but when i run it, it show me all the line where it found the code <UML:Class name= etc >
[php]
$file = ‘order.xml’;
$searchfor = ‘UML:Attribute name="’;
$contents = file_get_contents($file);
$pattern = preg_quote($searchfor, ‘’);
$pattern = “/^.$pattern.$/m”;
if(preg_match_all($pattern, $contents, $matches)){
echo “Found matches:\n”;
echo implode("\n", $matches[0]);
}
else{
echo “No matches found”;
}
[/php]
i dont know if i could do this away, or if i have to use the xml parser
thanks all