Exercise struts1.2 + hibernate3.1 programming in myeclipse5.1 these two days.
Struts and hibernate have been familiar with the basic syntax and core technologies intermittently over the past year, so they have found an example of RSS online reading.
In the middle, I encountered a problem of parsing RSS XML documents.
The core Parsing Code is as follows:
Public static list parsefeed (string address ){
// System. setproperty ("javax. xml. parsers. documentbuilderfactory", "com.sun.org. Apache. Crimson. JAXP. documentbuilderfactoryimpl ");
//
List <Object> result = new arraylist <Object> ();
//
Documentbuilderfactory DBF = documentbuilderfactory. newinstance ();
System. Out. println ("Factory:" + DBF );
//
Documentbuilder dB;
Document Doc;
Try {
//
DB = DBF. newdocumentbuilder ();
//
// Doc = dB. parse (Address );
Java. Io. File file = new java. Io. File (Address );
Doc = dB. parse (File );
//
Nodelist NL = Doc. getelementsbytagname ("item ");
//
For (INT I = 0; I <NL. getlength (); I ++ ){
Node node = NL. item (I );
Nodelist nl2 = node. getchildnodes ();
Node nodetitle = nl2.item (1 );
Node nodeauthor = nl2.item (2 );
Node nodeurl = nl2.item (3 );
Node nodedescription = nl2.item (4 );
String title = nodetitle. getfirstchild (). getnodevalue ();
String author = nodeauthor. getfirstchild (). getnodevalue ();
String url = nodeurl. getfirstchild (). getnodevalue ();
String description = nodedescription. getfirstchild (). getnodevalue ();
// Construct the item object based on the obtained information
// Item = new item (title, description, author, URL );
// Put the generated item into the result list for returning
// Result. Add (item );
}
}
Catch (parserconfigurationexception e ){
//
E. printstacktrace ();
}
Catch (saxexception e ){
//
E. printstacktrace ();
}
Catch (ioexception e ){
//
E. printstacktrace ();
} Finally {
//
// System. setproperty ("javax. xml. parsers. documentbuilderfactory", "com.sun.org. Apache. xerces. Internal. JAXP. documentbuilderfactoryimpl ");
Return result;
}
// Return result;
}
However, null is returned. I have viewed this statement:
Documentbuilderfactory DBF = documentbuilderfactory. newinstance ();
The value of DBF in is:
Com.sun.org. Apache. xerces. Internal. JAXP. documentbuilderfactoryimpl @ 8f4fb3
In the elseif column there is a dedicated discussion of this issue (URL: http://blog.csdn.net/elseif/archive/2005/04/29/367506.aspx)
Unfortunately, I used JDK 1.5.0 _ 06 without a package.
Org. Apache. Crimson. JAXP. documentbuilderfactoryimpl (in my case, the complete path should be com.sun.org. Apache. Crimson. JAXP. documentbuilderfactoryimpl), but this class does not exist. Because the package com.sun.org. Apache. Crimson. * cannot be found at all, I wonder if it is my JDK problem and I am looking for a solution ....