10 Replies Latest reply: Mar 7, 2008 4:08 PM by 807591 RSS

    Problem with XML parser

    807591
      Hi! Im getting errors while trying to parse an XML file.
      It did work for me, and the next day it didnt. Here is the code of the jsp:
      <%@ page language="java" %>
      <%@ page import="javax.xml.parsers.*" %>
      <%@ page import="org.w3c.dom.Document" %>
      <%@ page import="org.w3c.dom.Element" %>
      <%@ page import="org.w3c.dom.DOMException" %>
      <%@ page import="java.net.URL" %>
      <%@ page import="java.io.InputStream" %>
      <%@ page import="java.io.IOException" %>
      <%
      String xUrl = "http://"+request.getServerName()+"/test.xml";
      Document document;
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      
      try {
      URL u = new URL(xUrl);
      InputStream inputXML = u.openStream();
      DocumentBuilder builder = factory.newDocumentBuilder();
      document = builder.parse(inputXML);
      %>
      ...some of my own code in here
      <%
      }
      catch(Exception e)
      {
           String msg;
           msg = e.toString();
           out.println(msg);
      }
      %>
      And this is the code for the XML:
       <?xml version="1.0" encoding="UTF-8" ?> 
      - <ResultSet>
      - <Result>
      - <IdItem>
      - <![CDATA[ 015004
        ]]> 
        </IdItem>
      - <IdItem2>
      - <![CDATA[ 91719
        ]]> 
        </IdItem2>
      - <Item>
      - <![CDATA[ BANANA ADRIA 22XU
        ]]> 
        </Item>
      - <Id_Catalogo>
      - <![CDATA[ 110
        ]]> 
        </Id_Catalogo>
      - <Especificacion ID="1">
      - <![CDATA[ PE295
        ]]> 
        </Especificacion>
      - <Especificacion ID="11">
      - <![CDATA[ FE112
        ]]> 
        </Especificacion>
      - <Especificacion ID="12">
      - <![CDATA[ TCB15
        ]]> 
        </Especificacion>
      - <Especificacion ID="3">
      - <![CDATA[ MP28
        ]]> 
        </Especificacion>
      - <Especificacion ID="4">
      - <![CDATA[ FC63
        ]]> 
        </Especificacion>
      - <Especificacion ID="9">
      - <![CDATA[ FCP77
        ]]> 
        </Especificacion>
        </Result>
        </ResultSet>
      The error im getting is:
      java.io.IOException: Server returned HTTP response code: 500 for URL: http://e3sis017/test.xml
      That error gets triggered at line:
      InputStream inputXML = u.openStream();

      Any ideas?