XML parse error MalformedURLException: no protocol:

maeapple

New Member
I'm trying to modify a method from a program make it y JAVA 6.3 and I getting the following error "Malformed URL Exception".I'm using this code.\[code\]DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); try{ DocumentBuilder builder = factory.newDocumentBuilder(); DOMImplementation implementation = builder.getDOMImplementation(); Document document=implementation.createDocument(null, "xml", null); // Document document=implementation.; Element raiz = document.createElement("Correos");// creamos el elemento raiz Element elemento = document.createElement("Correo");//creamos un nuevo elemento Text text = document.createTextNode("[email protected]");//Ingresamos la info document.setXmlVersion("1.0");// asignamos la version de nuestro XML document.getDocumentElement().appendChild(raiz); //pegamos la raiz al documento raiz.appendChild(elemento); //pegamos el elemento hijo a la raiz elemento.appendChild(text); // Source source = new DOMSource(document); String datos=""; Result console= new StreamResult(System.out); Result result = new StreamResult(new java.io.File("resultado.xml"));//nombre del archivo Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.transform(source, result); transformer.transform(source, console); //transformer.t // DocumentBuilder db = new DocumentBuilder(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); //db.parse(datos) ; String xmlX =("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<xml>\n<Correos>\n<Correo>[email protected]</Correo>\n</Correos>\n</xml>"); db.parse(xmlX); //document; }catch(Exception e){ System.err.println("Error:" +e); }\[/code\]As you can see on line 31 I'm "wiring" the XML sending an String.The XML that I'm using I already test it on several Web navigators and I never get such error as in JAVA.Basically what I need is to create a "Document" variable because is that type of variable that is returned by the method that I need to modify.In the original method, not in the upper code, that code(the upper one) is another project that I'm use in order to debug a bigger code, is a method that returns a "Document".Here the original code that I need to modify.(The following code is inside of a try catch)\[code\]DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();DocumentBuilder db = dbf.newDocumentBuilder();InputStream input = HTMLTools.inputStream_GET(url, timeoutMS);InputStreamReader reader = new InputStreamReader(input, ENCODING_UTF8);InputSource inSrc = http://stackoverflow.com/questions/11037279/new InputSource(reader);inSrc.setEncoding(ENCODING_UTF8);return db.parse(inSrc);\[/code\]I don't understand very well the purpose of the method parse of the db variable.I thinking too that maybe I didn't need the db variable since I'm already have a variable type "Document" from the upper code.I already read the JavaDoc but I don't figure out how this codes works, basically the XML part.So basically I think that I'm getting messy, Can anyone clarify me what I doing wrong?Thanks.:-)
 
Back
Top