public static void main(String[] args) throws SAXException, ParserConfigurationException, IOException
{
String fXml="<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" +
"<Emp id=\"1\">\n" +
" <name>Pankaj</name>\n" +
" <age>25</age>\n" +
" <role>Developer</role>\n" +
" <gen>Male</gen>\n" +
"</Emp>";
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(fXml);
doc.getDocumentElement().normalize();
System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
}
I am getting the following errors:
Exception in thread "main" java.net.MalformedURLException: no protocol: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
How do I make work as intuitive? Yeah the problem lies in the very first line but I am not sure how to correct this.