Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6667267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:54:54+00:00 2026-05-26T02:54:54+00:00

I am reading an XML using dom4j by using XPath techniques for selecting desired

  • 0

I am reading an XML using dom4j by using XPath techniques for selecting desired nodes. Consider that my XML looks like this:

<Emp_Dir>
    <Emp_Classification type ="Permanent" >
        <Emp id= "1">
        <name>jame</name>
            <Emp_Bio>
                <age>12</age>
                <height>5.4</height>
        <weight>78</weight>
            </Emp_Bio>
            <Emp_Details>
                <salary>2000</salary>
        <designation>developer</designation>
            </Emp_Details>
        </Emp>
        <Emp id= "2">
        <name>jame</name>
            <Emp_Bio>
                <age>12</age>
                <height>5.4</height>
        <weight>78</weight>
            </Emp_Bio>
            <Emp_Details>
                <salary>2000</salary>
        <designation>developer</designation>
            </Emp_Details>
        </Emp>
    </Emp_Classification>

    <Emp_Classification type ="Contract" >
    .
    .
    .
    </Emp_Classification>

    <Emp_Classification type ="PartTime" >
    .
    .
    .
    </Emp_Classification>
</Emp_Dir>

Note: The above XML might looks ugly to you but i only create this dummy file for the sake of understanding and keeping the secracy of my project

When i specify some simple XPath expression, like:

//Emp_Classification (or)
/Emp_Dir/Emp_Classification

then its works fine but when i specify some complex expression like:

/Emp_Dir/Emp_Classification/[@type='Permanent'] (or)
//Emp_Dir/Emp_Classification/[@type='Permanent']

then it gives me the following error:

"Invalid XPath expression: /Emp_Dir/Emp_Classification/[@type='Permanent'] Expected one of '.', '..', '@', '*', <QName>"

Coulde anybody guides me what goes wrong in my XPath?

My second question is that how do i select the Emp_Bio node of Permanent Employees only, does this works?

//Emp_Dir/Emp_Classification/[@type='Permanent']/Emp/Emp_Bio
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:54:54+00:00Added an answer on May 26, 2026 at 2:54 am

    Use : //Emp_Dir/Emp_Classification[@type='Permanent']

    (note the removal of /)

    And then use this : //Emp_Dir/Emp_Classification[@type='Permanent']/Emp/Emp_Bio for the latter part of the question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading an XML using dom4j by using XPath techniques for selecting desired
I'm reading an XML file that looks like this: <?xml version=1.0 encoding=utf-8?> <VehicleList> <Vehicle>
I'm reading a XML file with dom4j. The file looks like this: ... <Field>&#13;&#10;
i'm reading liferay source code and found out that 2 xml files using same
I'm reading xml document using XPath and I need to create a Document object
I am reading a XML using SAX ( javax.xml.parsers.SAXParser; ). In that XML, there
I've been reading about XML, XSL, XPath, etc. I want to start this small
Im having some trouble reading xml files using jquery that containts swedish chars (åäö)
I am reading an xml file using javascript and then I need to submit
I'm reading some XML with PHP and currently using the DOMDocument class to do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.