Dom4j xpath prblem

Hi ,
I'm trying to parse the xml file below using dom4j xpath tool.
however the java code below give me an exception :
     java.lang.NoClassDefFoundError: org/jaxen/JaxenException
         at org.dom4j.DocumentFactory.createXPath(DocumentFactory.java:230)
         at org.dom4j.tree.AbstractNode.createXPath(AbstractNode.java:207)
         at org.dom4j.tree.AbstractNode.selectNodes(AbstractNode.java:164)
         at com.sun.star.addon.sugarcrm.soap.Sugar.getSearchInfo(Sugar.java:213)
         at test.SugarTestSuite.testGetSugarSearchInfo(SugarTestSuite.java:108)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at junit.framework.TestCase.runTest(TestCase.java:168)
         at junit.framework.TestCase.runBare(TestCase.java:134)
         at junit.framework.TestResult$1.protect(TestResult.java:110)
         at junit.framework.TestResult.runProtected(TestResult.java:128)
         at junit.framework.TestResult.run(TestResult.java:113)
         at junit.framework.TestCase.run(TestCase.java:124)
         at junit.framework.TestSuite.runTest(TestSuite.java:232)
         at junit.framework.TestSuite.run(TestSuite.java:227)
         at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
         at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
         at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
     what am i doing wrong ?
thanks for helping.
java code:
  try {
                   if (sugarSearchInfoArray == null)
                         SAXReader reader = new SAXReader();
                         Document document = reader.read(Utils.getResourceURL("/SugarSoap.ArchiveSettings.xml"));
                        ArrayList mlist = new ArrayList();
                        List list = document.selectNodes( "//Module/" );
                        for (Iterator iter = list.iterator(); iter.hasNext(); ) {
                            Node node = (Node) iter.next();
                            String module = node.valueOf( "@name" );
                            String defName = module;
                            _logger.debug("module->"+defName);
                            String strIcon=node.valueOf( "@icon" );
                            int num2=Integer.parseInt(strIcon);
                            _logger.debug("icon num->"+num2);
                            List list3 = node.selectNodes( "/SearchFields/*" );
                            List list4 = node.selectNodes( "/DisplayFields/*" );
                            for (Iterator iter3 = list3.iterator(); iter3.hasNext(); ){
                                 Node child = (Node) iter3.next();
                                String name = child.valueOf( "@name" );
                                _logger.debug("search field->"+name);
                                list3.add(name);
                            for (Iterator iter4 = list4.iterator(); iter4.hasNext(); ){
                                 Node child = (Node) iter4.next();
                                String name = child.valueOf( "@name" );
                                _logger.debug("display field->"+name);
                                list4.add(name);
                            SugarSearchInfo info = new SugarSearchInfo(module, null, num2, (String[]) list3.toArray(new String[list3.size()]), (String[]) list4.toArray(new String[list4.size()]));
                            mlist.add(info);
                        Module_list _list = this.soap.get_available_modules(this.sessionid);
                        if (_list.getError().getNumber().equals("0"))
                            boolean flag2 = false;
                            SugarSearchInfo[] sList=(SugarSearchInfo[])mlist.toArray(new SugarSearchInfo[mlist.size()]);
                            for (SugarSearchInfo info2 : sList)
                                for (String str5 : _list.getModules())
                                    if (info2.module.equals(str5))
                                        flag2 = true;
                                        break;
                                if (!flag2)
                                    list.remove(info2);
                        sugarSearchInfoArray = (SugarSearchInfo[]) mlist.toArray(new SugarSearchInfo[mlist.size()]);
              } catch (NumberFormatException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (RemoteException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (DocumentException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
             return sugarSearchInfoArray;
         }   the xml file :
<?xml version="1.0" encoding="utf-8" ?>
    <ArchiveOptions>
         <ArchiveModules>
              <Module name="Contacts" icon="0">
                   <SearchFields>
                        <Field name="contacts.last_name"/>
                        <Field name="contacts.first_name"/>
                   </SearchFields>
                   <DisplayFields>
                        <Field name="last_name"/>
                        <Field name="first_name"/>
                        <Field name="salutation"/>
                        <Field name="account_name"/>
                   </DisplayFields>               
              </Module>
              <Module name="Accounts" icon="1">
                   <SearchFields>
                        <Field name="accounts.name"/>
                   </SearchFields>
                   <DisplayFields>
                        <Field name="name"/>
                   </DisplayFields>
              </Module>
              <Module name="Opportunities" icon="2">
                   <SearchFields>
                        <Field name="opportunities.name"/>
                   </SearchFields>
                   <DisplayFields>
                        <Field name="name"/>
                   </DisplayFields>
              </Module>
              <Module name="Cases" icon="3">
                   <SearchFields>
                        <Field name="cases.name"/>
                   </SearchFields>
                   <DisplayFields>
                        <Field name="name"/>
                   </DisplayFields>
              </Module>
              <Module name="Bugs" icon="4">
                   <SearchFields>
                        <Field name="bugs.name"/>
                   </SearchFields>
                   <DisplayFields>
                        <Field name="name"/>
                   </DisplayFields>
              </Module>
              <Module name="Leads" icon="5">
                   <SearchFields>
                        <Field name="leads.first_name"/>
                        <Field name="leads.last_name"/>
                        <Field name="leads.account_name"/>
                   </SearchFields>
                   <DisplayFields>
                        <Field name="last_name"/>
                        <Field name="first_name"/>
                        <Field name="account_name"/>
                   </DisplayFields>
              </Module>
              <Module name="Project" icon="6">
                   <SearchFields>
                        <Field name="project.name"/>
                   </SearchFields>
                   <DisplayFields>
                        <Field name="name"/>
                   </DisplayFields>
              </Module>
              <Module name="ProjectTask" icon="7">
                   <SearchFields>
                        <Field name="project_task.name"/>
                   </SearchFields>
                   <DisplayFields>
                        <Field name="name"/>
                   </DisplayFields>
              </Module>
              <Module name="Documents" icon="8">
                   <SearchFields>
                        <Field name="documents.document_name"/>
                   </SearchFields>
                   <DisplayFields>
                        <Field name="document_name"/>
                        <Field name="document_revision"/>
                   </DisplayFields>
              </Module>
         </ArchiveModules>
    </ArchiveOptions>  

thanks
i added the missing jaxen.jar to classpath.
now the error disappeared but I'm not getting the right results.
i changed my code to this :
if (sugarSearchInfoArray == null)
                     SAXReader reader = new SAXReader();
                     Document document = reader.read(Utils.getResourceURL("/SugarSoap.ArchiveSettings.xml"));
                    ArrayList mlist = new ArrayList();
                    List list = document.selectNodes( "//Module" );
                    for (Iterator iter = list.iterator(); iter.hasNext(); ) {
                        Node node = (Node) iter.next();
                        String module = node.valueOf( "@name" );
                        String defName = module;
                        _logger.debug("module->"+defName);
                        String strIcon=node.valueOf( "@icon" );
                        int num2=Integer.parseInt(strIcon);
                        _logger.debug("icon num->"+num2);
                        List list3 = document.selectNodes(node.getUniquePath()+"/SearchFields/descendant::*" );
                        _logger.debug("list3->"+list3.size());
                        for (Iterator iter3 = list3.iterator(); iter3.hasNext(); ){
                             Node child = (Node) iter3.next();
                            String name = child.valueOf( "@name" );
                            _logger.debug("search field->"+name);
                            list3.add(name);
                        List list4 = document.selectNodes( node.getUniquePath()+ "/DisplayFields/descendant::*" );
                        for (Iterator iter4 = list4.iterator(); iter4.hasNext(); ){
                             Node child = (Node) iter4.next();
                            String name = child.valueOf( "@name" );
                            _logger.debug("display field->"+name);
                            list4.add(name);
                        SugarSearchInfo info = new SugarSearchInfo(module, null, num2, (String[]) list3.toArray(new String[list3.size()]), (String[]) list4.toArray(new String[list4.size()]));
                        mlist.add(info);
                    Module_list _list = this.soap.get_available_modules(this.sessionid);
                    if (_list.getError().getNumber().equals("0"))
                        boolean flag2 = false;
                        SugarSearchInfo[] sList=(SugarSearchInfo[])mlist.toArray(new SugarSearchInfo[mlist.size()]);
                        for (SugarSearchInfo info2 : sList)
                            for (String str5 : _list.getModules())
                                if (info2.module.equals(str5))
                                    flag2 = true;
                                    break;
                            if (!flag2)
                                list.remove(info2);
                    sugarSearchInfoArray = (SugarSearchInfo[]) mlist.toArray(new SugarSearchInfo[mlist.size()]);
                    }unfortunately I get this exception :
java.util.ConcurrentModificationException
     at java.util.AbstractList$Itr.checkForComodification(Unknown Source)
     at java.util.AbstractList$Itr.next(Unknown Source)
     at com.sun.star.addon.sugarcrm.soap.Sugar.getSearchInfo(Sugar.java:227)
     at test.SugarTestSuite.testGetSugarSearchInfo(SugarTestSuite.java:108)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
     at java.lang.reflect.Method.invoke(Unknown Source)
     at junit.framework.TestCase.runTest(TestCase.java:168)
     at junit.framework.TestCase.runBare(TestCase.java:134)
     at junit.framework.TestResult$1.protect(TestResult.java:110)
     at junit.framework.TestResult.runProtected(TestResult.java:128)
     at junit.framework.TestResult.run(TestResult.java:113)
     at junit.framework.TestCase.run(TestCase.java:124)
     at junit.framework.TestSuite.runTest(TestSuite.java:232)
     at junit.framework.TestSuite.run(TestSuite.java:227)
     at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
     at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
     at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)what's wrong this time with the code ?
thanks much

Similar Messages

  • Using DOM4J XPath

    IM going nuts trying to use DOM4J to query something so simple. Here is the input XML file and the code to run the XPath. If I loop through the document using the annoying element and node map thing it works fine and I can get all the nodes. But I want to run an XPath query right to the information I want. Firs time I tried without the URI nodes and this time I tried it with it. Still no luck.
    XML FILE
    <?xml version="1.0"?>
    <configs>
         <config SERVICE="Service Name">
              <detail name="key">value</detail>
         </config>
         <config SERVICE="ProcessErrors">
              <detail name="ErrorEmailAddresses">[email protected]</detail>
         </config>
         <config SERVICE="TestSQLErrors">
              <detail name="ErrorEmailAddresses">[email protected]</detail>
         </config>     
    </configs>CODE
    File fXmlFile = new File("n:\\config.xml");
    DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
    Document doc = dBuilder.parse(fXmlFile);
    doc.getDocumentElement().normalize();
    XPath xpathNodes = new DefaultXPath("//configs/config[@SERVICE='ProcessErrors']/detail[@name='ErrorEmailAddresses']");
    HashMap<String, String> mapNodes = new HashMap<String,String>();
    xpathNodes.setNamespaceURIs(mapNodes);          
    Node exceptionNode = (Node)xpathNodes.selectSingleNode(doc);
    System.out.println(exceptionNode);exceptionNode is empty. If I run this same query on the same document in XML spy I get the value.???

    For obscure products it's generally better to ask on the forum or mailing list associated with that product. You're more likely to encounter people who have heard of the product and actually know something about it.
    On the other hand if it doesn't have a forum or mailing list, or there's no activity on that forum or mailing list, that's a hint you should consider using something more commonly used.

  • Dom4j xpath problem

    Hello all
    I have several methods in which I noticed strange behavior
    Here is the example:
    I create xpath as object because of performance, cause i use it on thousands of files
    XPath pathSpanPodzakonska = DocumentHelper.createXPath("//span[@class='palnk']");
    I found h4 element via xpath with relative path to h4 element...
    That works fine so far and founds h4 element that I need to.
    final Element elementH4= (Element) document.selectSingleNode("//h4[@id='someId']");
    Now i need to found some element inside that h4 tag
    but what I get is first element in document, outside h4 element !!!
    final Node nodeSpanPodzakonska = pathSpanPodzakonska.selectSingleNode(elementH4);
    That works same even if i write
    final Node nodeSpanPodzakonska = elementH4.selectSingleNode("//span[@class='palnk']");
    If I write code with absolute xpath that works fine when the span is directly inside of h4 but this isn't always case and cant depend on that.
    And more important have some other similar methods and want to clarify what happens in this xpath implementations and how can I use it in the best way.
    final Node nodeSpanPodzakonska = elementH4.selectSingleNode("span[@class='palnk']");
    Danilo Cubrovic

    Sorry. I will have to think about the XPath question in more detail.
    As to the side by side comparison: I meant of - open source HTML parsers
    http://java-source.net/open-source/html-parsers
    and also of XML frameworks that support XPath (such as DOM4j vs XOM).
    I am going to try HTMLParser with XOM, as I have, in informal speed testing, seen HTMLParser to be quite fast compared to others.
    The reason I would like to have speed is that I am working on a Web automation toolkit:
    www.mkosh.com
    and it looks like I will be re-parsing the entire tree after many Javascript commands.
    I would like to make this as speedy as possible. HTMLParser seems to win hands down, although if it does not work with real world HTML, that could be an issue.
    I will have to test.
    Thank you so much
    Misha

  • XPath and dom4j xs:date() conversion exception

    Hey all Java folks
    I'm having a hard time deadling with XPath and date datatype using dom4J and seeking for guidance :)
    Let say I have the following XML header:
    <site:Blog xmlns:site="http://xml.netbeans.org/schema/blog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:schemaLocation="http://xml.netbeans.org/schema/blog blog.xsd">and this expression :
    site:Blog//site:Entry[@date=xs:date('2007-09-07')]In XMLSpy I do get correct results but in my java code all I get is this exception:
    org.dom4j.XPathException: Exception occurred evaluting XPath: /site:Blog//site:Entry[@date=xs:date("2007-09-07")] Exception: No Such Function xs:date
    at org.dom4j.xpath.DefaultXPath.handleJaxenException(DefaultXPath.java:374)
    at org.dom4j.xpath.DefaultXPath.selectNodes(DefaultXPath.java:134)
    at org.dom4j.tree.AbstractNode.selectNodes(AbstractNode.java:166)
    at com.mor.blogengine.util.xpath.SearchEngine.getEntriesforDate(SearchEngine.java:142)
    at com.mor.blogengine.util.xpath.SearchEngineTest.testGetEntriesforDate(SearchEngineTest.java:120)Does anyone has a clue of why it works perfectly outside of JAVA but not within my code ?
    Any enlightenment is welcome! :)
    Laurent

    String xPathExpr= "/documentFiles/documentFile[xs:date(documentDateXML) > xs:date(\"2005-05-21\")]";should of course be
    String xPathExpr= "/documentFiles/documentFile[xs:date(documentDate) > xs:date(\"2005-05-21\")]";

  • Parsing XMLTV file with Dom4J

    Hi,
    I'm fairly new to Java programming, although I manage to usually do what I want in JSP, since they usually only contain small scriptlets.
    But when it comes to pure Java programming, I'm don't feel at home. My program below parses an XMLTV (http://xmltv.org) file, and my intention is to insert it's data in a database, but so far, I'm only using System.out.println() and piping the output to a file, which I then in turn import into SQL Query Analyzer and populate my database.
    I would like to just have some pointers if there is any other (I just feel there is), better way of coding what I have done. Perhaps other metods, like with Get/Set?
    package java2db;
    import java.util.*;
    import java.text.*;
    import org.dom4j.Document;
    import org.dom4j.DocumentException;
    import org.dom4j.Element;
    import org.dom4j.io.SAXReader;
    * @author chka
    public class Java2Db {
        private static Document document;
        /** Creates a new instance of Java2Db */
        public Java2Db() {
        public static String formatStr(String instr) {
            instr = instr.replaceAll("'","''");
            /*instr = instr.replaceAll("'","'");
            instr = instr.replaceAll("\"",""");
            instr = instr.replaceAll(">",">");
            instr = instr.replaceAll("<","<");*/
            return instr;
        public static void main(String[] args) {
                 String szActor = "";
                    String szDirector = "";
                    String szStart = "";
                    String szEnd = "";
                    String szChId = "";
                    String szTitle = "";
                    String szSubTitle = "";
              String szID = "";
                    String szChannel = "";
                    String szAspect = "";
                    String szIcon = "";
                    String szDisplayNameLang = "";
                    String szDate = "";
                    String szDescription = "";
                    String szCategory = "";
                    String szEpisodeNum = "";
              Date startTime = null;
              Date endTime = null;
              SimpleDateFormat xmlDateFormat = new SimpleDateFormat("yyyyMMddHHmmss Z");
              SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
              SAXReader reader = new SAXReader();
              try {
                        document = reader.read(args[0]);
                        //document = reader.read("c:/development/tvguide.xml");
                    Element rootElement = document.getRootElement();
                    Iterator itChannel = rootElement.elementIterator("channel");
              while (itChannel.hasNext() ) {
                        Element chElement = (Element) itChannel.next();
                        szID = chElement.attribute("id").getStringValue();
                        szChannel = chElement.element("display-name").getText();
                        szDisplayNameLang = chElement.element("display-name").attribute("lang").getStringValue();
                        if (chElement.element("icon") != null) {
                            szIcon = chElement.element("icon").attribute("src").getStringValue();
                        } else
                        szIcon = "";
                        System.out.println("insert into channel (displayname,lang,channelid,iconsrc) values ('"+szChannel+"','"+szDisplayNameLang+"','"+szID+"','"+szIcon+"')");
              Iterator itProgramme = rootElement.elementIterator("programme");
              while (itProgramme.hasNext() ) {
                   Element pgmElement = (Element) itProgramme.next();
                            szChId = pgmElement.attribute("channel").getStringValue();
                            szStart = pgmElement.attribute("start").getStringValue();
                   szEnd = pgmElement.attribute("stop").getStringValue();
                   szTitle = pgmElement.element("title").getText();
                            if (pgmElement.element("sub-title") != null) {
                                szSubTitle = pgmElement.element("sub-title").getText();
                            } else
                                szSubTitle = "";
                            if (pgmElement.element("video") != null) {
                                szAspect = pgmElement.element("video").element("aspect").getText();
                            } else
                                szAspect = "";
                            if (pgmElement.element("credits") != null) {
                                StringBuffer sb = new StringBuffer();
                                if (pgmElement.element("credits").element("director") != null ) { // There can be more than 1 director, should be handled.
                                    szDirector = formatStr(pgmElement.element("credits").element("director").getText());
                                else szDirector = "";
                                Iterator itActor = pgmElement.element("credits").elementIterator("actor");
                                while (itActor.hasNext()) {
                                    Element elementActor = (Element) itActor.next();
                                    sb.append(formatStr(elementActor.getText())+";");
                                szActor = sb.toString();
                            } else {
                                szDirector = "";
                                szActor = "";
                            if (pgmElement.element("date") != null) {
                                szDate = pgmElement.element("date").getText();
                            } else
                                szDate = "";
                            if (pgmElement.element("category") != null) {
                                StringBuffer sb = new StringBuffer();
                                List listCategory = pgmElement.elements("category");
                                Iterator itCategory = listCategory.iterator();
                                while (itCategory.hasNext()) {
                                    Element elementCategory = (Element) itCategory.next();
                                    sb.append(elementCategory.getText()+";");
                                szCategory = sb.toString();
                            } else
                                szCategory = "";
                            if (pgmElement.element("episode-num") != null) {
                                List listEpisode = pgmElement.elements("episode-num");
                                Iterator itEpisode = listEpisode.iterator();
                                while (itEpisode.hasNext()) {
                                    Element elementEpisode = (Element) itEpisode.next();
                                    if (elementEpisode.attribute("system").getStringValue().equalsIgnoreCase("onscreen")) {
                                        szEpisodeNum = elementEpisode.getText();
                            } else
                                szEpisodeNum = "";
                            if (pgmElement.element("desc") != null) {
                        szDescription = formatStr(pgmElement.element("desc").getText() );
                   } else
                                szDescription = "";
                            try {
                                startTime = xmlDateFormat.parse(szStart);
                                endTime = xmlDateFormat.parse(szEnd);
                            catch (ParseException pe) {
                                System.out.println(pe.getMessage());
                            System.out.println("insert into programme (title,subtitle,channelid,starttime,endtime,copyrightdate,aspect,category,episodenum,director,actor,description) values ('"+formatStr(szTitle)+"','"+formatStr(szSubTitle)+"','"+szChId+"','"+sdf.format(startTime)+"','"+sdf.format(endTime)+"','"+szDate+"','"+szAspect+"','"+formatStr(szCategory)+"','"+szEpisodeNum+"','"+szDirector+"','"+szActor+"','"+szDescription+"')");
                    } // try
              catch (Exception e) {
                   System.out.println("! Exception: "   );
                            e.printStackTrace();
    }Thanks for any suggestions on how I can improve this small program!
    --chris                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    1. Only the value of one "system" attribute will be assigned to the "szEpisodeNum" variable, even if there are several "tv/programme/episode-num" elements, so the below loop is useless. Didn't you by any chance want to concatenate the elementEpisode.getText() values to a single string (as you do with the values of the "tv/programme/category" elements) or did you omit a break statement?> while (itEpisode.hasNext()) {
    Element elementEpisode = (Element) itEpisode.next();
    if (elementEpisode.attribute("system").getStringValue().equalsIgnoreCase("onscreen")) {
    szEpisodeNum = elementEpisode.getText();
    }2. You wrote:
    There can be more than 1 director, should be handled.They are not handled in your code. If you want to do so, you should process them in a loop as you do with the actors.
    3. The below if statement is not prepared for handling "tv/programme/episode-num" elements that do not have a "system" attribute, which throw a NullPointerException.> if (elementEpisode.attribute("system").getStringValue().equalsIgnoreCase("onscreen")) {
    szEpisodeNum = elementEpisode.getText();
    }4. I rewrote your Java2Db class using XPath queries. My class is almost equivalent with yours, the only difference being that my class does not apply formatting on date values. This would have necessitated adding an extra few lines which would have detracted from the readability of the code.import java.util.ArrayList;
    import java.util.List;
    import org.dom4j.Document;
    import org.dom4j.DocumentException;
    import org.dom4j.DocumentHelper;
    import org.dom4j.io.SAXReader;
    import org.dom4j.Node;
    import org.dom4j.XPath;
    * Generates SQL queries for inserting data from org.dom4j.Node nodes into a database table.
    * @author prgguy
    public class Java2Db {
       * Generates SQL queries for inserting data from org.dom4j.Node nodes into a database table.
       * @param node    The node, or its descendant nodes, of which the data will be inserted as
       *                records into a database table.
       * @param table   The name of the database table that the records will be inserted into.
       * @param entity  The XPath definition of the nodes that will be interpreted as entities
       *                in the database.
       * @param record  Stores the field names (in the 1st dimension) and the values
       *                (in the 2nd dimension) of the records.
       * @param returns A list containing the SQL queries that insert the records into the table.
      public static ArrayList<String> getSQLCommands(Node node, String table, String entity, String[][] record) {
        ArrayList<String> sqlList = new ArrayList<String>();
        String fields = "";
        String values = "";
        String value = "";
        String sqlcommand = "";
        String comma;
        XPath xp = DocumentHelper.createXPath(entity);
        List entList = xp.selectNodes(node);
        List subList = null;
        Node entNode = null;
        Node subNode = null;   
        for (int i = 0; i < entList.size(); i++) {
          entNode = (Node)entList.get(i);
          for (int j = 0; j < record.length; j++) {
            xp = DocumentHelper.createXPath(record[j][1]);
            subList = xp.selectNodes(entNode);
            for (int k = 0; k < subList.size(); k++) {
              subNode = (Node)subList.get(k);
              value += subNode.getText() + (subList.size() > 1? ";": "");
            comma = (j == record.length - 1)? "" : ",";
            fields += record[j][0] + comma;
            values += (subNode == null? "''" : ("'" + value + "'")) + comma;
            value = "";
          sqlcommand = "insert into " + table + " (" + fields + ") values (" + values + ")";
          sqlList.add(sqlcommand);
          fields = "";
          values = "";
        return sqlList;
      public static void main(String[] args) {
        Document document = null;
        try {
          SAXReader reader = new SAXReader();
          document = reader.read("c:/development/tvguide.xml");
        catch (DocumentException e) {
          e.printStackTrace();
        // In this section we define the entities that will provide the records. The definitions
        // are written in XPath language.
        // This array defines the records of the "channel" entity.
        String[][] record_channel = {
          {"displayname",   "display-name"},
          {"lang",          "display-name/@lang"},
          {"channelid",     "@id"},
          {"iconsrc",       "icon/@src"}
        // This array defines the records of the "programme" entity.
        // The fields "episodenum" and "director" are restricted to contain only one value (node)
        // per field. I only did it to make my code work exactly as your code does so that
        // the output of your code and mine will be easy to compare.
        String[][] record_programme = {
          {"title",         "title"},
          {"subtitle",      "sub-title"},
          {"channelid",     "@channel"},
          {"starttime",     "@start"},
          {"endtime",       "@stop"},
          {"copyrightdate", "date"},
          {"aspect",        "video/aspect"},
          {"category",      "category"},
          {"episodenum",    "episode-num[@system='onscreen'][last()]"},
          {"director",      "credits/director[1]"},
          {"actor",         "credits/actor"},
          {"description",   "desc"}
        // Now let's see what we have done:
        String sqlcommand;
        ArrayList<String> sqlList;
        sqlList = getSQLCommands(document, "channel", "tv/channel", record_channel);
        for (int i = 0; i < sqlList.size(); i++) {
          sqlcommand = sqlList.get(i);
          System.out.println(sqlcommand);
        sqlList = getSQLCommands(document, "programme", "tv/programme", record_programme);
        for (int i = 0; i < sqlList.size(); i++) {
          sqlcommand = sqlList.get(i);
          System.out.println(sqlcommand);
    }

  • Getting Invalid XPath expression

    Hi,
    I am parsing a XML document and reading a node with <xtags:valueOf .. select="product_name"/>. The value of product_name is :
    <product_name>SJE6 2004Q1, 1 RTU ESD, All platforms, 1 Year</product_name> , but I am getting the following exception :
    org.dom4j.InvalidXPathException: Invalid XPath expression: SJE6 2004Q1, 1 RTU ESD, All platforms, 1 Year Unexpected '2004'
    at org.dom4j.xpath.DefaultXPath.parse(DefaultXPath.java:316)
    at org.dom4j.xpath.DefaultXPath.<init>(DefaultXPath.java:63)
    at org.dom4j.DocumentFactory.createXPath(DocumentFactory.java:182)
    at org.dom4j.DocumentFactory.createXPath(DocumentFactory.java:198)
    at org.apache.taglibs.xtags.xpath.AbstractTag.createXPath(AbstractTag.java:195)
    at org.apache.taglibs.xtags.xpath.VariableTag.setSelect(VariableTag.java:143)
    I tried with <xtags:copyOf select=.../node() and text()/> but still getting the same exception. Not sure why its failing on 2004? Help!
    Thanks,
    -Ashish

    The problem was not in the <xtags:valueOf> but in the following expression :
    <xtags:variable id="lName" select="<%= product_name %>"/>
    where I wasassigning the value of <product_name> to a String (java) variable defined. But this will be another question : why is <xtags:variable> failing?

  • Problem with selectNodes() in dom4j & jboss

    Hi,
    Iam facing some problem in parsing an xml file.
    The xml file is parsed perfectly and iam able to display the data inside it also using the rootelement.
    when iam calling selectNodes(Xpath expression), iam getting a ClassNotFoundException. i pasted Dom4j1.6.8.jar and jaxen-full.jar in JBoss server lib.
    Then also the problem is not solved. Here is my java file method, XML file and Exception.
    public static HashMap getDBConfigurtion() throws DAOException{
                XMLConfig xmlMain = new XMLConfig();
             String str = "../../../xml/config/config.xml";
            Document document = null;
            try {
              System.out.println("Inside GetDBConfiguration Try .. Before parse");
                document = xmlMain.parse(str);
                  System.out.println("INSIDE TRY AFTR DOC.. Nodes no.."+ document.nodeCount()+"Node Type is.."+document.getNodeType());
                //HashMap hash=new HashMap();
                //hash=document.
                return xmlMain.getConfig(document);
             } catch (Exception e) {
                 throw new DAOException("Excepiton in getDBConfiguration",e,false);
    public Document parse(String url) throws DocumentException {
            SAXReader reader = new SAXReader();
            Document document = reader.read(url);
            return document;
        public HashMap getConfig(Document document) throws DocumentException {
          //read the datasources
             System.out.println("XML CONFIG:: getConfig");/////////////////this is printed
            List lisNodes =  (List) document.selectNodes("//dbconfig/dbparams/datasources/datasource");//////////////ERROR HERE -NOT EXECUTED
            System.out.println("After selectNodes..size is"+lisNodes);
            for(int i=0;i<lisNodes.size();i++)
                 System.out.println("In for"+lisNodes.get(i));
            HashMap hmDataSources = new HashMap();
            for (Iterator iter = lisNodes.iterator(); iter.hasNext(); ) {
               Node n = (Node)iter.next();
               System.out.println("Node is.."+n.getName());
               hmDataSources.put(n.valueOf("@id"), n.getText());
               System.out.println("Datasources id:"+ n.valueOf("@id")+": Text :" + n.getText());
    /* begin config.xml*/
    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE dbconfig SYSTEM "dbconfig.dtd">
    <dbconfig>
         <dbparams>
              <datasources>
                   <datasource Id="dsmysql">java:/MySQLDB</datasource>
              </datasources>
              <sqlproperties>
                   <sqlproperty id="maxfetchsize">10</sqlproperty>
                   <sqlproperty id="restrictchars">x</sqlproperty>
                   <sqlproperty id="deleteAllowed">false</sqlproperty>
              </sqlproperties>
         </dbparams>
         <!-- specifies the sqlrepositories locations -->
         <sqlrepositorypath>
              <sqlrepository Id="id1">../../../xml/module1/selectsql.xml</sqlrepository>
         </sqlrepositorypath>
    </dbconfig>
    /*end of file config.xml */
    Exception:-
    java.lang.NoClassDefFoundError: org/dom4j/xpath/DefaultXPath
    org.dom4j.DocumentFactory.createXPath(DocumentFactory.java:230)
    org.dom4j.tree.AbstractNode.createXPath(AbstractNode.java:207)
    org.dom4j.tree.AbstractNode.valueOf(AbstractNode.java:189)
    com.tsd.common.XMLConfig.getDBConfigurtion(Unknown Source)
    com.tsd.dao.DBDelegator.getSqlContext(Unknown Source)
    com.tsd.dao.DBDelegator.invoke(Unknown Source)
    BackingClass.display(Unknown Source)
    UserBean.display(Unknown Source)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    please give me some idea to resolve this.

    JBoss is using Dom4J for their own stuff: it probably supersedes your version. So you have to either:
    * forget Dom4J and use JAXP, which is standard and offer all you need,
    * replace Dom4J that ships with JBoss with yours (in JBOSS_ROOT/lib), but this might have adverse consequences

  • Dom4j InvalidXPathException problem

    Hi,
                    <textItem id="1">
                   <title>first</title>
                   <displayText>number one</displayText>
                   <displayGraphic filename="uno"/>
              </textItem>
    xp = DocumentHelper.createXPath("//textItem@id");When I run the above xpath expression on the xml code I get :
    org.dom4j.InvalidXPathException: Invalid XPath expression: //hotTextItem@id Unexpected '@'
    at org.dom4j.xpath.DefaultXPath.parse(DefaultXPath.java:360)
    at org.dom4j.xpath.DefaultXPath.<init>(DefaultXPath.java:59)
    at org.dom4j.DocumentFactory.createXPath(DocumentFactory.java:230)
    at org.dom4j.DocumentHelper.createXPath(DocumentHelper.java:121)
    I am sure that this is the correct xpath string to use. Is it?
    thanks,
    Hugh

    inabind wrote:
    I am sure that this is the correct xpath string to use. Is it?That looks remarkably silly, as the second sentence directly contradicts the first sentence. And you really know that it isn't correct, don't you? Try not to get caught up in wishful thinking and egoistic behaviour. It just gets in the way of problem-solving.
    Anyway, no, that isn't a valid XPath expression. (That's what the error message says.) I expect your next question would have been how to make it correct, but that can't be answered without knowledge of what the expression was intended to find.

  • Jars in the class path of a custom component

    I am using the dom4j-1.6.1.jar library in a custom component, but my JBoss server has dom4j.jar in jboss\server\all\lib.  My custom component is throwing the following error:
    DefFoundError message:org/dom4j/xpath/DefaultXPath while invoking service XmlToCsvService and operation convert and no fault routes were found to be configured.
    This makes me suspect that the version of Dom4J in the lib directory of the server is taking precedence over the one in my component.  Any suggestions for how to deal with this?  Thanks.
    Jared Langdon

    Even Marcel's suggestion may not always work, but it certainly is worth a quick try.  I seem to remember trying that and finding that one of the LiveCycle EAR files has a version of dom4j buried inside it (I don't remember which version of LC it was).
    Of course altering an Adobe supplied EAR is not recommended and may violate your support ageement. There is an alternative, however; if changing the JBoss lib folder doesn't work.  To avoid the conflict you can use JarJar to rename the packages within the DOM4J class and deploy the renamed jar with your component to avoid the conflict.
    http://code.google.com/p/jarjar/
    You would then use the renamed classes in your component:
    import org.mypackage.dom4j.Document;
    import org.mypackage.dom4j.DocumentException;
    import org.mypackage.dom4j.DocumentHelper;
    import org.mypackage.dom4j.Element;
    import org.mypackage.dom4j.Node;
    import org.mypackage.dom4j.io.DOMReader;
    import org.mypackage.dom4j.io.DOMWriter;

  • Please Help Me! Getting a fragment of a XML String

    Im working on an application which read xml metadata from a database, parses some fragments of it, and stores some fragments in another database to parse later, so i have the following as a String:
    <article>
    <article-title>...<article-title>
    <article-body>...</article<body>
    <references>
    <reference id=1>...</reference>
    <reference id=2>...</reference>
    </references>And i need to extract the following String (not just the text value, but the whole fragment with tag names and everything):
    <references>
    <reference id=1>...</reference>
    <reference id=2>...</reference>
    </reference>How can i do this using xpath expressions? is that even possible? is there any other way to this at all?
    thank you for your help.

    First of all must to build an small well formed XML document with the fragment read from database.
    Parse this built XML as possible to retrieve intended fragment.
    You can use SAX, DOM, JDOM, DOM4J, XPath, etc, but being an small document don't need a "gun machine"! Use XPP or SAX (event driven parser).
    How can i do this using xpath expressions? is that even possible? is there any other way to this at all?XPath expression //references returns the XML fragment:
    <references>
      <reference id="1">...</reference>
      <reference id="2">...</reference>
    </references>since built XML is:
    <?xml version="1.0" encoding="utf-8"?>
    <article>
      <article-title>...</article-title>
      <article-body>...</article-body>
      <body>
        <references>
          <reference id="1">...</reference>
          <reference id="2">...</reference>
        </references>
      </body>
    </article>and "yes", even possible if XML is well formed as above.
    As alternative you can use specialized methods like getElementsByTagName and getElementById from org.w3c.DOM API.
    Don't forget to take a look at XPP and SAX. You can't imagine how easy and fast it should be.

  • What's wrong with my XPath statement using dom4j?

    I'm pretty new to XML. However, I did pick up a book and I'm pretty much through it. I got a copy of dom4j and I created a sample XML file. I'm able to parse the data and find out the child elements of root but I'm having problems with using XPath no matter what I do. Here's my code:
    import org.dom4j.*;
    import org.dom4j.io.*;
    import java.util.*;
    import java.io.*;
    public class XMLACL {
      org.dom4j.Document doc;
      org.dom4j.Element root;
      XMLACL(String x) {
        String tempFile = System.getProperty("user.dir") + "/winsudo.xml";
        tempFile = tempFile.replace('\\', '/');
        SAXReader xmlReader = new SAXReader();
        try {
          doc = xmlReader.read(tempFile);
        catch (Exception e) {}
        root = doc.getRootElement();
        //treeWalk();
        //iterateRootChildren("grant");
        XPath xpathSelector = DocumentHelper.createXPath("/grant[@prompt='no']");  
        List results = xpathSelector.selectNodes(doc);
        for (Iterator iter = results.iterator(); iter.hasNext(); ) {
         Element element = (Element) iter.next();
          System.out.println(element.getName());
    }And here's my XML:
    <?xml version="1.0" encoding="UTF-8"?>
    <config>
         <alias name="admin">
              <user>geneanthony</user>
              <user>mike</user>
              <user>rob</user>
         </alias>
         <grant prompt="no" runas="root" service="no">
              <user>geneanthony</user>
              <command>!ALL</command>
         </grant>
         <grant>
              <user>geneanthony</user>
              <group>users</group>
              <command>C:/Program Files/Mozilla Firefox/firefox.exe</command>
         </grant>
         <grant>
              <alias>admin</alias>
              <command>!Panels</command>
         </grant>
    </config>I'm currently getting this error:
    C:\Borland\JBuilder2005\jdk1.4\bin\javaw -classpath "C:\code\java\WinSudo\classes;C:\Borland\JBuilder2005\jdk1.4\jre\javaws\javaws.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\charsets.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\ext\dnsns.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\ext\ldapsec.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\ext\localedata.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\ext\sunjce_provider.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\im\indicim.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\im\thaiim.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\jce.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\jsse.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\plugin.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\rt.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\sunrsasign.jar;C:\Borland\JBuilder2005\jdk1.4\lib\dt.jar;C:\Borland\JBuilder2005\jdk1.4\lib\htmlconverter.jar;C:\Borland\JBuilder2005\jdk1.4\lib\tools.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\jRegistryKey.jar;C:\Borland\JBuilder2005\jdk1.4\lib\hsqldb.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\dom4j-1.6.1.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\syntax.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\IzPack-install-3.7.2.jar" winsudo.Main
    java.lang.NoClassDefFoundError: org/jaxen/JaxenException
         at org.dom4j.DocumentFactory.createXPath(DocumentFactory.java:230)
         at org.dom4j.DocumentHelper.createXPath(DocumentHelper.java:121)
         at winsudo.XMLACL.<init>(XMLACL.java:26)
         at winsudo.Main.main(Main.java:15)
    Exception in thread "main"
    Can someone tell me what's wrong with my code. None of the samples I've seen came with the XML files so I don't know if I when I start the XPATH I need to use / for the root element, or // or a forward slash and the root name. Can I please get some help!

    Thank you! I didn't haven Jaxen I thought everything was in the package and I must have missed it in the tutorials. That resolved the dropouts and I think I'm good know. I couldn't think for the life of me what I was doing wrong!

  • JAVA XML DOM4J: Invalid XPath expression

    Hi everybody,
    I am not sure why I am getting an exception for this expression:
    Number count= document.numberValueOf("/NODE/SUBNODE/count(*)");
    Exception is:
    org.dom4j.InvalidXPathException: Invalid XPath expression:
    Thanks regards
    Mario

    Hello
    what about
    "count (/NODE/SUBNODE)" as xpath expression
    regards franz
    reward points if useful

  • JAVAMapping dom4j: Invalid XPath expression:

    Hi ervybody,
    I am not sure why I am getting an exception for this expression:
    Number count= document.numberValueOf("/NODE/SUBNODE/count(*)");
    Exception is:
    org.dom4j.InvalidXPathException: Invalid XPath expression:
    Thanks regards
    Mario

    The problem is
    You don't have the correct version of jaxen or one of its dependencies on the classpath.
    Please update your DOM Parser beta12.
    Please visit the link.
    http://jira.codehaus.org/browse/JAXEN-175

  • Using XPath to create nodes

    Hi,
    Obviously the main use of XPath is to query the state of an XML document... the equivalent to a "select" statement in SQL.
    DOM4J has methods that allow you to use XPath as the equivalent to "insert" statements in SQL. You can specify an XPath like "/Hello/World/Value = 3" and apply this XPath to an XML document so that it creates something like this for you:
    <Hello>
    <World>
    <Value>3</Value>
    </World>
    </Hello>
    This is actually very useful for an investment banking application that I'm working on.
    The problem with DOM4J is that it doesn't handle attributes or conditionals well. If you specify
    /Hello[@name=2]/World = 3
    I would expect
    <Hello name=2>
    <World>3</World>
    </Hello>
    to be produced. Instead, it produces
    <Hello[@name=2]>
    <World>3</World>
    </Hello>
    These are all simple examples. What I'm doing in real life is using XPath to insert nodes into a complicated XML document that already has a lot of structure. I'm only adding one or two elements to big documents.
    Is there anything at all like this available in the JDK 1.5 release. I've had a good look, and XPath looks like it's only for queries. Is this correct?

    I think this might do what you need...
    // Create a dummy XML document
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    InputStream bais = new ByteArrayInputStream("<test><e1/></test>".getBytes());       
    Document doc = db.parse(bais);
    // Define the XPath expression to "select" the parent element in the document       
    XPath xpath = XPathFactory.newInstance().newXPath();
    XPathExpression xpathExpression = xpath.compile("/test/e1");    
    // Select the parent node (should probably chuck an ex if not present)       
    Node node = (Node) xpathExpression.evaluate(doc, XPathConstants.NODE);
    // Create and append the child element
    node.appendChild(doc.createElement("newElement"));
    // Convert the Document into a string
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DOMSource source = new DOMSource(doc);
    StreamResult result = new StreamResult(baos);
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    transformer.transform(source, result);
    // <?xml version="1.0" encoding="UTF-8"?><test><e1><newElement/></e1></test>
    System.out.println(baos.toString());

  • Dom4J Node or Element Get Detail

    I've ran through all the methods on the dom4J Element and Node. I'm having an issue. I have a SOAP envelope with an header and a body. In the body there is a detail xml that has the type of request.
    I get the body Node here correctly below.
    try
             bodyNode = myDoc.selectSingleNode("//soapenv:Envelope/soapenv:Body");
             LOG.debug("bodyNode as XML : " + bodyNode.asXML());
        catch(Exception e)
             LOG.debug("Cant find bodyNode : ", e);
        }If I do the asXML() method I get.
    <SOAP-ENV:Body>
         <IdentifyMember xmlns="http://soa.com/IdentificationService/">
              <IdentifyMemberRequest xmlns="http://soa.com/IdentificationService/">
                   <FirstName xmlns="http://soa.com/IdentifyRequestSchema">= John</FirstName>
                   <LastName xmlns="http://soa.com/IdentifyRequestSchema">= Smith</LastName>
              </IdentifyMemberRequest>
         </IdentifyMember>
    </SOAP-ENV:Body>This is correct. But I need to just get any xml between the body. For instance in this one I want the entire IdentifyMember element. I don't want to use index and substring and all of that. I was assuming there was already a method that would return me the following in either the Node or the Element. And I don't know what is coming in between those body tags so it has to be generic. Any Ideas?
    <IdentifyMember xmlns="http://soa.com/IdentificationService/">
              <IdentifyMemberRequest xmlns="http://soa.com/IdentificationService/">
                   <FirstName xmlns="http://soa.com/IdentifyRequestSchema">= John</FirstName>
                   <LastName xmlns="http://soa.com/IdentifyRequestSchema">= Smith</LastName>
              </IdentifyMemberRequest>
         </IdentifyMember>

    The Node API has methods that allow you to figure out things like the first child element of a particular node. getNodeList, for example. But I also think XPath allows you to search for the first element of a particular node, by a combination of wildcards and predicates. Something like this should work:
    //soapenv:Envelope/soapenv:Body/*[1]See the XPath tutorial for more details:
    [http://www.w3schools.com/XPath/xpath_syntax.asp]

Maybe you are looking for

  • Looking for a side pouch that will accept the Blackberry with a skin on

    Hi, New to the Blackberry world and to the forum.  I just picked up a Blackberry Curve 8330 thru Verizon.  I really like it and the Verizon horizontal side pouch with the magnet device.  Does anyone know of a slightly larger pouch that will allow me

  • Why is Apple not supporting Firewire on the new Video 60g or the Nano

    Does anyone know if there is a way to enable Firewire support on the new Video IPod or NANO. I cannot believe that Apple has released this product with only USB support. I am at 1 hr to upload 1000 songs out of 9000. Absurd. Is there an update or a w

  • External hard disc "disappeared"!

    Hi, I upgraded to Lion on my 2.66GZ Intel Core 2 Duo about a month ago. After 3 weeks my new Iomega external hard disk which I used with Time Machine was no longer recognised or appeared as a device in Finder. The Iomega hard disc (top of the range m

  • Every three secs. a pop-up window prompts me to Select a Wireless Network. I hit cancel and it does it again.

    Every three seconds a pop-up window prompts me to Select a Wireless Network. I select the network then a window tells me it's unable to connect to the network although it is connected. I hit cancel and it goes away for three seconds and returnees con

  • Itunes purchased smart list

    I just recently noticed that the songs I buy through iTunes are no longer being put in my "purchased" smart list. I still get them in my library. How can I turn this feature back on? I enjoy having my purchased music in the list. Thanks