racy
asked on
How to parse multiple tags and their attributes
I have the following xml snippet. I'd like to parse through the Link tags and print their individual attributes:
<Link Name="Accounts Receivable" URL="/images/class1.flash" ></Link>
<Link Name="Accounts Payable" URL="/images/payable.flash "></Link>
<Link Name="Payroll Clerk" URL="/images/clerk1.flash" ></Link>
<Link Name="Posting Clerk" URL="/images/clerk1.flash" ></Link>
<Link Name="General Office Clerk" URL="/images/clerk1.flash" ></Link>
<Link Name="Title Clerk/Billing Clerk" URL="/images/clerk1.flash" ></Link>
Something like the following only prints the attributes of the first link tag. Can this be done with simplexml?
<?php
$xml = simplexml_load_file("train ing.xml");
foreach($xml->TitleBar->Ti tleBarLink s->Link[0] ->attribut es() as $a => $b) {
echo $a,'="',$b,"\"\n";
}
<Link Name="Accounts Receivable" URL="/images/class1.flash"
<Link Name="Accounts Payable" URL="/images/payable.flash
<Link Name="Payroll Clerk" URL="/images/clerk1.flash"
<Link Name="Posting Clerk" URL="/images/clerk1.flash"
<Link Name="General Office Clerk" URL="/images/clerk1.flash"
<Link Name="Title Clerk/Billing Clerk" URL="/images/clerk1.flash"
Something like the following only prints the attributes of the first link tag. Can this be done with simplexml?
<?php
$xml = simplexml_load_file("train
foreach($xml->TitleBar->Ti
echo $a,'="',$b,"\"\n";
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER