Hi!
Ich habe folgenden XML-String, aus dem ich drei float werte und drei strings auslesen möchte und in variablen abspeichern möchte:
Bis jetzt war ich erfolgreich im parsen des Tags <FreeTextAnnotation> mit folgendem Code:
Aber wie ich den Zahlenwert confidence="0.0230340" hinter <TextAnnotation type= ....> auslesen soll, ist mir ein rätsel.
Kann mir jemand helfen?!
Gruß beaf
Ich habe folgenden XML-String, aus dem ich drei float werte und drei strings auslesen möchte und in variablen abspeichern möchte:
Code:
<Mpeg7 xmlns="urn:mpeg:mpeg7:schema:2004" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:mpeg:mpeg7:schema:2004 ./davp-2005.xsd" xmlns:mpeg7="urn:mpeg:mpeg7:schema:2004">
<DescriptionMetadata>
<Creator>
<Role href="" />
<Agent xsi:type="OrganizationType">
<Name>Organisation</Name>
</Agent>
</Creator>
</DescriptionMetadata>
<Description xsi:type="ContentEntityType">
<MultimediaContent xsi:type="AudioVisualType">
<AudioVisual>
<StructuralUnit href="urn:x-mpeg-7-sat:cs:AudioVisualSegmentationCS:root" />
<MediaSourceDecomposition criteria="sat image annotation segment">
<StillRegion>
<StructuralUnit href="urn:x-mpeg-7-sat:cs:SegmentationCS:image" />
<CreationInformation>
<Creation>
<Title />
</Creation>
</CreationInformation>
<TextAnnotation type="urn:x-mpeg-sat:cs:HLDescriptorCS:image:ImageClass" confidence="0.667455">
<FreeTextAnnotation>Gruppe1</FreeTextAnnotation>
</TextAnnotation>
<TextAnnotation type="urn:x-mpeg-sat:cs:HLDescriptorCS:image:ImageClass" confidence="0.345565">
<FreeTextAnnotation>Gruppe2</FreeTextAnnotation>
</TextAnnotation>
<TextAnnotation type="urn:x-mpeg-sat:cs:HLDescriptorCS:image:ImageClass" confidence="0.027433">
<FreeTextAnnotation>Gruppe3</FreeTextAnnotation>
</TextAnnotation>
</StillRegion>
</MediaSourceDecomposition>
</AudioVisual>
</MultimediaContent>
</Description>
</Mpeg7>
Bis jetzt war ich erfolgreich im parsen des Tags <FreeTextAnnotation> mit folgendem Code:
Code:
private static void xmlParsing (String response) throws Exception {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
InputSource is = new InputSource();
is.setCharacterStream(new StringReader(response));
Document doc = db.parse(is);
NodeList nodes = doc.getElementsByTagName("TextAnnotation");
for (int i = 0; i < nodes.getLength(); i++) {
Element element = (Element) nodes.item(i);
NodeList mood = element.getElementsByTagName("FreeTextAnnotation");
Element line = (Element) mood.item(0);
System.out.println("Klasse: " + getCharacterDataFromElement(line));
}
}
public static String getCharacterDataFromElement(Element e) {
Node child = e.getFirstChild();
if (child instanceof CharacterData) {
CharacterData cd = (CharacterData) child;
return cd.getData();
}
return "?";
}
Aber wie ich den Zahlenwert confidence="0.0230340" hinter <TextAnnotation type= ....> auslesen soll, ist mir ein rätsel.
Kann mir jemand helfen?!
Gruß beaf