//mdpbatxt.xml <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?> <!-
ID: 3800118 • Letter: #
Question
//mdpbatxt.xml
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!--
New Perspectives on XML
Case Problem 2
MDPBA Competition Roster
Author:
Date:
Filename: mdpba.xml
Supporting Files: mdpba.xsd
-->
<bands>
<band cid="c0001">
<name grade="juvenille">School of Celtic Bagpipes & Drumming</name>
<city>Delafield</city>
<logo source="celtic.png" />
<competition>
<event type="MSR">
<tune>Charlie's Welcome</tune>
<tune>Mrs MacPherson of Inveran</tune>
<tune>Brown Haired Maiden</tune>
</event>
<event type="Medley">
<tune>Rowd's Hornpipe</tune>
</event>
</competition>
</band>
<band cid="c0002">
<name grade="juvenille">Badger Pipes and Drums</name>
<city>Madison</city>
<logo source="badger.png" />
<competition>
<event type="MSR">
<tune>Lord Alexander Kennedy</tune>
<tune>Bob of Fettercairn</tune>
<tune>Brown Haired Maiden</tune>
</event>
<event type="Medley">
<tune>Out of the Air</tune>
</event>
</competition>
</band>
<band cid="c0003">
<name grade="juvenille">Pardeeville School of Piping and Drumming</name>
<city>Pardeeville</city>
<competition>
<event type="MSR">
<tune>Lord Alexander Kennedy</tune>
<tune>Bob of Fettercairn</tune>
<tune>The Little Cascade</tune>
</event>
<event type="Medley">
<tune>The Radar Racketeer</tune>
</event>
</competition>
</band>
<band cid="c0004">
<name grade="1">Zoar Scottish Pipe Band</name>
<city>Zoar</city>
<competition>
<event type="MSR">
<tune>Charlie's Welcome</tune>
<tune>Mrs MacPherson of Inveran</tune>
<tune>Major Manson</tune>
</event>
<event type="Medley">
<tune>Miss Lily</tune>
</event>
</competition>
</band>
<band cid="c0005">
<name grade="novice">Stockholm Pipe Band</name>
<city>Stockholm</city>
<competition>
<event type="MSR">
<tune>Pretty Marion</tune>
<tune>The Sheepwife</tune>
<tune>Brown Haired Maiden</tune>
</event>
<event type="Medley">
<tune>Farewell to Erin</tune>
</event>
</competition>
//mdpbatxt.xsd
<?xml version="1.0" encoding="UTF-8" ?>
<!--
New Perspectives on XML
Case Problem 2
MDPBA schema
Author:
Date:
Filename: mdpba.xsd
Supporting Files: mdpba.xml
-->
Explanation / Answer
logo element:
Elements elements = doc.getElementsByTag("img");
for (Element element : elements) {
//Searching the src tag inside img tag
logo =element.attr("src");
String logo1=logo;
//If src link has substring logo
if(logo1.toLowerCase().contains("logo")|| element.attr("alt").toLowerCase().contains("logo"))
{
if(!logo.contains("http"))
{
if(!logo.startsWith("/"))
logo=link + "/"+logo;
else
logo=link+logo;
}
System.out.println(logo);
logoflag=1;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.