Hi guys
Further to a previous post that i made i've been trying to print some xml from a .wmdb (windows media database) file. The file itself basically stores metadata about media that has been played using windows media player. However the file also contains lots of other junk in it and not just xml, but i'm only concerned with printing the xml from the file to the consle for now. The follwoing is some xml taken from the file:
< M E T A D A T A x m l n s : s q l = " u r n : s c h e m a s - m i c r o s o f t - c o m : x m l - s q l " >
< M D R - C D >
< v e r s i o n > 4 . 0 < / v e r s i o n >
< W M C o l l e c t i o n I D > 9 9 9 F B C 3 A - E 1 E A - 4 F 9 A - A B 8 3 - A 9 A 8 C A 0 D F 7 F B < / W M C o l l e c t i o n I D >
< W M C o l l e c t i o n G r o u p I D > 9 9 9 F B C 3 A - E 1 E A - 4 F 9 A - A B 8 3 - A 9 A 8 C A 0 D F 7 F B < / W M C o l l e c t i o n G r o u p I D >
< m d q R e q u e s t I D / >
< u n i q u e F i l e I D > A M G a _ i d = R 2 0 6 7 1 4 < / u n i q u e F i l e I D >
< a l b u m T i t l e > M T V U n p l u g g e d i n N e w Y o r k < / a l b u m T i t l e >
< a l b u m A r t i s t > N i r v a n a < / a l b u m A r t i s t >
< r e l e a s e D a t e > 1 9 9 4 - 1 1 - 0 1 < / r e l e a s e D a t e >
< l a b e l > D i v i n e R e c o r d i n g s < / l a b e l >
< g e n r e > R o c k < / g e n r e >
< p r o v i d e r S t y l e > R o c k < / p r o v i d e r S t y l e >
< p u b l i s h e r R a t i n g > 9 < / p u b l i s h e r R a t i n g >
The code that i'm using is as follows. It's basically the same as the DOMParseExample on this website. For the meantime i've just tried to get the program to read the tag WM Collection ID as you can see below.
However the program seems to compile with no errors, but when i try to run it i get the following error:
[Fatal Error] CurrentDatabase_360.wmdb:1:1: Content is not allowed in prolog.
org.xml.sax.SAXParseException: Content is not allowed in prolog.
at com.sun.org.apache.xerces.internal.parsers.DOMPars er.parse(DOMParser.java:264)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBu ilderImpl.parse(DocumentBuilderImpl.java:292)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBu ilder.java:172)
at DOMParseExample.main(DOMParseExample.java:16)
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; import java.io.*; public class DOMParseExample { public static void main(String[] args) { File file = new File("CurrentDatabase_360.wmdb"); try { DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document doc = builder.parse(file); NodeList nodes = doc.getElementsByTagName("Metadata"); for (int i = 0; i < nodes.getLength(); i++) { Element element = (Element) nodes.item(i); NodeList WMCollectionID = element.getElementsByTagName("WMCollectionID"); Element line = (Element) WMCollectionID.item(0); System.out.println("WM Collection ID: " + line.getFirstChild().getTextContent()); System.out.println(); } } catch (Exception e) { e.printStackTrace(); } } }
I'm not sure whether this is because the program doesn't recognize the file or maybe it's because there is other data in the file asides from xml.
Any help on this would be much appreciated as i'm stumped!
Thanks
John