error parsing xml with JAXB
in
Programming Questions
•
2 years ago
I'm trying to load the itunes xml file.
I get this error:
error parsing xml:
javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"plist"). Expected elements are <{}dict>
at
etc.
I don't understand a bit of the JAXB when it comes to deeper nested stuff.
This is what i have so far:
pde:
AppConfig.java
I get this error:
error parsing xml:
javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"plist"). Expected elements are <{}dict>
at
etc.
I don't understand a bit of the JAXB when it comes to deeper nested stuff.
This is what i have so far:
pde:
- // JAXB is part of Java 6.0, but needs to be imported manually
import javax.xml.bind.*;
// our little data class for storing config settings
// this class is defined in its own tab in the Processing PDE
AppConfig config;
void setup() {
// the following 2 lines of code will load the config.xml file and map its contents
// to the nested object hierarchy defined in the AppConfig class (see below)
try {
// setup object mapper using the AppConfig class
JAXBContext context = JAXBContext.newInstance(AppConfig.class);
// parse the XML and return an instance of the AppConfig class
//config = (AppConfig) context.createUnmarshaller().unmarshal(createInput("config.xml"));
config = (AppConfig) context.createUnmarshaller().unmarshal(createInput("iTunes Music Library_doeke.xml"));
} catch(JAXBException e) {
// if things went wrong...
println("error parsing xml: ");
e.printStackTrace();
// force quit
System.exit(1);
}
println("done");
}
void draw() {
}
AppConfig.java
import java.util.*;
import javax.xml.bind.annotation.*;
// this annoation marks the AppConfig class to be able to act as
// an XML root element. The name parameter is only needed since
// our XML element name is different from the class name:
// <config> vs. AppConfig
@XmlRootElement(name="dict")
public class AppConfig {
}
1