Xerces Parser Help needed URGENT

Hi, I am trying to write a parser that can parse a XML file, and then use RSS to make a feed of my own XML schemas.
I need help in the Xerces XML parser part. Does anyone have sample code for using Xerces XML parser in parsing a XML file, by tagnames ..etc , or maybe tell me how I can parse XML file such as :
 <List name = "something">
     <Item>item a</Item>

Where i will have multiple List,
I want to parse the List-Name, and the Item, description, prices(and all the individual Price)

The xml file can be located on disk or on web.

I read up on the RSS feed creation on java.sun.com especially the rome library.

How do I create feed that can be displayed as :

<List name = "something">
     <Item>item a</Item>

Thanks for your help,
if you have sourcecode and would rather like to email please email to me at
<e-mail removed from Venabili>
(If you do email please let me know you emailed)

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You could use XPath to get your List nodes:

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(new File(args[0]));
XPath xpath = XPathFactory.newInstance().newXPath();
final String findList = "//List";
NodeList nodeList = (NodeList) xpath.evaluate(findList, document, XPathConstants.NODESET);
for(int i = 0;i < nodeList.getLength();i++) {

Step-by-step on writing feeds



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

Please do not post your e-mail in questions -- all the communication should be lead on the site. I removed it from here.

Java Page Editor
Although I haven't tested

this might help you

import org.xml.sax.AttributeList;
import org.xml.sax.HandlerBase;
import org.xml.sax.Parser;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.helpers.ParserFactory;
import org.xml.sax.XMLReader;
import org.apache.xerces.parsers.SAXParser;
import java.io.*;

import java.util.*;

public class SAXParserXercesTest1
     extends HandlerBase { //implements org.xml.sax.ContentHandler

   * handler method, this is invoked in starting of every element while reading the XML document

             public void startElement(String name, AttributeList attrs)

                  list=new AList();
                  list.name = atts.getName(0);



   * handler method, this is invoked in ending of every element while reading the XML document
    public void endElement(String name)
    } //

   * handler method, this is invoked in after startElement while reading the XML document
   public void characters(char ch[], int start, int len){

    String str = new String(ch, start, len);




  public static void main(String s[]) throws Exception
                                 long startTime=System.currentTimeMillis() ;
        SAXParser parser = new SAXParser();
        SAXParserXercesTest1 handler = new SAXParserXercesTest1();

             long endTime=System.currentTimeMillis() ;
             System.out.println("Xerces Sax Parser  : Time taken to parse the document for "+s[0]+" times is :"+((endTime-startTime)/1000));


      private Vector getITemLists()
            return lists

String node;
AList list=null;
Vector lists=new Vector();

class AList
      private String name;
      private String item;
      private String desc;
      private Vector prices;
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

I would recommend using JAXP (Part of JDK 1.4 and downloadable from SUN).  The code will be something like this:

DocumentBuilder build=DocumentBuilderFactory.newDocumentBuilder();
Document doc=build.parse(xmlFileName);
NodeList listNodes=doc.getElementsByTagName("List-Name ");
for(i=0;i<listNodes.getLength();i++) {
   Element parElement=(Element) listNodes.item(i);
   AList list=new AList();

   //Get the  Item, description, prices nodes
      ...extract the price node just like you did list-name


Also check out this thread:
lordianoAuthor Commented:
When I create Feed using ROME library, How can i create it so that it will have custome tag names?
I am creating it like :

entry = new SyndEntryImpl();
entry.setTitle("Rome v0.1");
description = new SyndContentImpl();
description.setValue("Initial release of Rome");

but this would be displayed as
    <title> .... </title>
    <link>.... </link>
    <summary type = ............../>

Is there a way I can rename the tag "entry" to something else?
and is there a way I can create custom tag other than title, link, entry..???

I will split points accordingly THANKS a lot for the help
Check the dtd or schema for the xml used - that will tell you what you can and can't use
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.