You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by shams jawaid <sh...@hotmail.com> on 2007/12/07 16:16:08 UTC

SAXParser Help, *Urgent*

Hi  Im been trying below to make it work since 4 weeks now. Any 1 please help me.  i have attached: MyElement.java, MySAXParserBean.java, saxparser.jar, test.xml in the saxparser.zip file, please have a look     I'm trying to reterive xml file attributes on Client-side when accessing web service. Actually I have more than 1 web services and I want my client take address of each webservice from xml at runtime(XML file is attached). I'm using SAX Parser for XML. I made a jar file of SAX Parser classes (MYSAXParserBean.java & MyElement.java. Both classes are SAXPArser) and put that in axis2/WEB-INF/lib. the problem is when Im accessing this jar file getting error of MYSAXParseBean is undefined class. where as the same java coding works well when I access SAX Parser classes as pure java. Following is the code which I use to retrieve the attribute ( which works as Java but not as JSP). So If I put all this in conclusion I have an XML file and SAXParserBean & MyElement are SAXParser classes and the code below to access the SAXParser to retrieve and print. <%@ page import='java.io.*,org.apache.axis2.client.*,org.apache.axis2.addressing.*,org.apache.axiom.om.*,javax.xml.namespace.*,java.util.Iterator,javax.activation.DataHandler,java.awt.Image,javax.imageio.ImageIO,org.apache.axis2.Constants,org.apache.axis2.engine.DefaultObjectSupplier,org.apache.axis2.*,org.xml.sax.Attributes.*,saxparser.*,java.util.*, javax.servlet.http .* ' %>  <% try { MySAXParserBean p = new MySAXParserBean(); Collection v = p.parse('c://test.xml');Iterator it = v.iterator();while(it.hasNext()) {MyElement element = (MyElement)it.next();String tag = element.getLocalName();String qName = element.getQname();String at = element.getAttributes();String url = element.getAttributes1();if(qName.equals('HSP')) {if(at.equals('HSP1')){out.println('Attribute HSP: ' + at); out.println('Attribute HSP: ' + url);}else if(at.equals('HSP2')){out.println('Attribute HSP2: ' + at); out.println('Attribute HSP2: ' + url);}else if(at.equals('HSP3')){out.println('Attribute HSP3: ' + at); out.println('Attribute HSP3: ' + url);}else if(at.equals('HSP4')){System.out.println('Attribute HSP4: ' + at); System.out.println('Attribute HSP4: ' + url);}else if(at.equals('HSP5')){out.println('Attribute HSP5: ' + at); out.println('Attribute HSP5: ' + url);}else if(at.equals('HSP6')){out.println('Attribute HSP6: ' + at); out.println('Attribute HSP6: ' + url);}else if(at.equals('HSU1')){System.out.println('Attribute HSPU: ' + at); out.println('Attribute HSPU: ' + url);}} else if(qName.equals('HSU')) {out.println('Attribute HSU: ' +url);} } } catch (Exception e) {}%>
_________________________________________________________________
Who's friends with who and co-starred in what?
http://www.searchgamesbox.com/celebrityseparation.shtml