I don't know of any off hand, but here are a few functions the I wrote that
might help you get started with JAXP. just read the javadocs and look at
this code and it is not that hard. good luck,

Jimmy



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 13, 2001 5:57 PM
To: [EMAIL PROTECTED]
Subject: JAXP


                Hi all,

                Does anyone know of a site that has good JAXP examples?
Thanks, BB.

--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

import java.util.*;
import java.io.*;
import javax.xml.parsers.*;
import org.xml.sax.*;
import org.w3c.dom.*;
import org.apache.crimson.tree.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;


/*----------------------------------*/

 public static Document readXML(String xml_path){

      DocumentBuilderFactory DTFactory = null;
      DocumentBuilder DBuilder = null;
      Document XMLDoc = null;

        try{
            DTFactory = DocumentBuilderFactory.newInstance();
            DBuilder = DTFactory.newDocumentBuilder();
            XMLDoc = DBuilder.parse(new FileInputStream(xml_path));
        }
        catch (IOException ieo){
            System.err.println("file does not exist");}

        catch (Exception e){ System.out.println("exception in util");
                              System.err.println(e); }

        return XMLDoc;

  }//readXML()

/*----------------------------------*/

public static void writeXMLToFile(Document xmlDoc, String xml_path){
     xmlDoc.getDocumentElement().normalize();
     XmlDocument xmlFile = (XmlDocument)xmlDoc;
     try{
       xmlFile.write(new FileOutputStream(xml_path));
        }
     catch (FileNotFoundException fnf) {System.out.println(fnf);}
     catch (IOException ioe) { System.out.println(ioe); }
  }//writeXMLToFile()


/*----------------------------------*/

 public static boolean areSiblings(Node first, Node second){

      if (first.getParentNode().equals(second.getParentNode()))
        return true;
      else return false;
  }//areSiblings(Node, Node)

    /** inserts into the XML in alphabetical order
     *  @param Element parentElement
     *  @param Element newElement
     */
    public static void insertByOrder(Element ParentElement, Element NewElement)
    {
      boolean b_inserted = false;
      String NodeName = NewElement.getAttribute(Constants.node_name);
      
      NodeList NL = ParentElement.getChildNodes();

      for (int i = 0; i < NL.getLength(); i++)
      {
         if (NL.item(i).getNodeType() != Node.ELEMENT_NODE)
         {
            continue;
         }

         Element thisElement = (Element)NL.item(i);
         String thisName = thisElement.getAttribute(Constants.node_name);
         if (NodeName.compareToIgnoreCase(thisName) < 0 )
         {
            ParentElement.insertBefore(NewElement, thisElement);
            b_inserted = true;
            break;
         }
      }

      if (!b_inserted)
      {
         ParentElement.appendChild(NewElement);
      }
  }//insertbyOrder(Element, Element)

--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to