| Subject: RE: parse using DOM From: "Paul Beer" <paul.beer@xxxxxxxxxxxx> Date: Wed, 2 Feb 2000 10:17:18 -0500 | 
i got rid of the construct syntax error, but I get a filetype error trying
to input the data to the parser.
Any suggestions ?
<%@ page import="java.io.*"%>
<%@ page import="org.w3c.dom.*"%>
<%@ page import="org.apache.xerces.parsers.DOMParser"%>
<%@ page import="org.apache.xerces.framework.XMLParser"%>
<%@ page import="org.xml.sax.InputSource"%>
<%
     DOMParser parser = new DOMParser();
     FileInputStream filename = new FileInputStream("foo.xml");
     parser.parse(filename);
     Document fdoc = parser.getDocument();
%>
<%=fdoc%>
error:
D:\Java\JavaWebServer2.0\tmpdir\default\pagecompile\jsp\_xml\_Dom__IBM.java:
89: Incompatible type for method. Can't convert java.io.FileInputStream to
org.xml.sax.InputSource.
parser.parse(filename);
i also get a similar error if I try to pass a string value :
String st = "<?xml version='1.0'?><name>Jack</name>";
StringReader reader = new StringReader(st);
     DOMParser parser = new DOMParser();
     parser.parse(reader);
     Document fdoc = parser.getDocument();
error :
D:\Java\JavaWebServer2.0\tmpdir\default\pagecompile\jsp\_xml\_Dom__IBM.java:
89: Incompatible type for method. Can't convert java.io.StringReader to
org.xml.sax.InputSource.
parser.parse(reader);
-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxx]On Behalf Of Herbert Hirscher
Sent: Wednesday, February 02, 2000 2:56 AM
To: xsl-list@xxxxxxxxxxxxxxxx
Subject: Re: parse using DOM
Hi!
Paul Beer schrieb:
> does anyone know why this code fails :
>
> all I want to do is output the packet .....
>
> <%@ page import="java.io.*"%>
> <%@ page import="org.w3c.dom.*"%>
> <%@ page import="org.apache.xerces.parsers.DOMParser"%>
> <%@ page import="org.xml.sax.InputSource"%>
>
> <%
> String filename = "foo.xml";
> DOMParser parser = new DOMParser(filename);
In DOM-Api there is no constructor with a string-argument.
try this:
=> DOMParser parser = new DOMParser();
>
> Document fdoc = parser.parse();
=> parser.parse(new FileInputStream(filename));
to get the document:
=> Document fdoc = parser.getDocument();
>
>
> %>
>
> the error is :
>
>
D:\Java\JavaWebServer2.0\tmpdir\default\pagecompile\jsp\_xml\_Dom__IBM.java:
> 91: Wrong number of arguments in constructor.
> DOMParser parser = new DOMParser(filename);
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
I have tested this with oracle-parser, i think it should also work in your
case.
Herbert Hirscher.
 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
| Current Thread | 
|---|
| 
 | 
| <- Previous | Index | Next -> | 
|---|---|---|
| Re: parse using DOM, Herbert Hirscher | Thread | Re: parse using DOM, Warren Hedley | 
| RE: multiple input files to one out, Linda van den Brink | Date | Re: Use of document() and an Engli, Steve Tinney | 
| Month |