Regarding my question on how to parse out a value from an XML string: The
following is the method I use to create the string:


To create my XML String, I call the following method from a JSP.
The method passes a stored procedure from an Oracle database to an EJB that
actually generates the XML.
I return the XML String to the JSP.

public String getPlatformServerClusterDash(){
         try {
          String xml_string = "";
               xml_string += "<PLATFORM__CLUSTER_SERVER_DASHBOARD>";

          // Get the Context for the Query EJB
          Context ctx = getContext(url, user, password);
          ssga.QueryBeanHome home = (ssga.QueryBeanHome) ctx.lookup
("QueryBean");

          // call the stored procedure for the QueryBean EJB to extract the
XML from database.
          ssga.QueryBean the_ejb = home.create("EXECUTE
inventory.get_cluster_id_for_server( ?, " + PLATFORM_ID + " )");

                    xml_string += "\n<PLATFORM_GET_CLUSTER_ID_FOR_SERVER>";
          xml_string += the_ejb.getXML();
          xml_string += "\n</PLATFORM_GET_CLUSTER_ID_FOR_SERVER>";

          xml_string += "</PLATFORM__CLUSTER_SERVER_DASHBOARD>";

          // release the memory
            the_ejb.remove();

           // return the raw XML string
          return xml_string;

         }
          catch (Exception e) {
               e.printStackTrace();
               return "Error: PlatformServerClusterDash";
          }
     }

Sharlene Sallet



                                                                                
                                     
                    Krzysztof Zielinski                                         
                                     
                    <krzysztof.zielinsk        To:     [EMAIL PROTECTED]        
                             
                    [EMAIL PROTECTED]>                 cc:                      
                                             
                                               Subject:     Re: simple 
question?                                     
                    05/17/2001 05:47 PM                                         
                                     
                    Please respond to                                           
                                     
                    xerces-dev                                                  
                                     
                                                                                
                                     
                                                                                
                                     




How do you get that string ? from a file ?

[EMAIL PROTECTED] schrieb:
>
> Hello,
>
> I am brand new to xml and parsing with Xerces.
>
> I have an XML String in a Java class that looks like this:
>
> <PLATFORM__CLUSTER_SERVER_DASHBOARD>
> <PLATFORM_GET_CLUSTER_ID_FOR_SERVER>
> <_data>
> <_record>
> <CLUSTER_ID><![CDATA[22165]]></CLUSTER_ID>
> </_record>
> </_data>
> </PLATFORM_GET_CLUSTER_ID_FOR_SERVER>
> </PLATFORM__CLUSTER_SERVER_DASHBOARD>
>
> All I want to do is pull out the value for CLUSTER_ID, which is "22165"
so
> I can assign it to a variable.
>
> I have a Xerces parser class and imported
>
> this stuff:
>
> import org.xml.sax.XMLReader;
> import org.xml.sax.helpers.XMLReaderFactory;
> import org.xml.sax.SAXException;
> import java.io.IOException;
> import org.xml.sax.ContentHandler;
>
> can anyone tell me how I can accomplish this?
>
> Thanks in advance,
>
> Sharlene




Reply via email to