2

I have the following and want to retrieve data where the 'FromEmail' is not empty

<FILE NAME="NewbusQuote">
   <REC NAME="level1">
        <FLD NAME="CoverPage"></FLD>
        <FLD NAME="FromEmail"></FLD>
       </REC>

    <REC NAME="leve2">
        <FLD NAME="CoverPage">Simple</FLD>
        <FLD NAME="FromEmail">[email protected]</FLD>
    </REC>


    <REC NAME="leve3">
        <FLD NAME="CoverPage"></FLD>
        <FLD NAME="FromEmail"></FLD>
    </REC>
</FILE>

Thank you in advance

3
  • Using string-length() comes to mind. Commented Jan 30, 2014 at 22:41
  • 1
    Get which data? What should the output look like? Commented Jan 30, 2014 at 22:43
  • @ Wrikken, I shall try that I just don't know how to go around it when names come to play.@ lwburk, sorry I forgot to mention proper, the non empty FromEmail is the one I want. Commented Jan 30, 2014 at 22:46

1 Answer 1

2

This XPath

/FILE/REC/FLD[@NAME = 'FromEmail']

will return FLD elements with attribute FromEmail, but this query

/FILE/REC/FLD[@NAME = 'FromEmail']/text()

will return only text content of second FromEmail element.

XPath in general doesn't retrieve empty elements (it's the same like if they were <FLD NAME="FromEmail" />).

to get all data from all elements with FromEmail atributte, use this

/FILE/REC//FLD[@NAME = 'FromEmail']/text()

Hope it helps

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.