cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Doubt with XPath expression Using XML

former_member740482
Participant
0 Likes
889

Dear experts,

I am creating the following iflow:

The iflow have the folling information:

<?xml version="1.0" encoding="UTF-8" ?>
<articles>
    <article>
        <title>First steps in Java</title>
        <author id="1">
            <firstname>Siena</firstname>
            <lastname>Kerr</lastname>
        </author>
        <release-date>2018-12-01</release-date>
    </article>
    <article>
        <title>Dockerize your SpringBoot application</title>
        <author id="2">
            <firstname>Jonas</firstname>
            <lastname>Lugo</lastname>
        </author>
        <release-date>2018-12-01</release-date>
    </article>
    <article>
        <title>SpringBoot tutorial</title>
        <author id="3">
            <firstname>Daniele</firstname>
            <lastname>Ferguson</lastname>
        </author>
        <release-date>2018-06-12</release-date>
    </article>
    <article>
        <title>Java 12 insights</title>
        <author id="1">
            <firstname>Siena</firstname>
            <lastname>Kerr</lastname>
        </author>
        <release-date>2018-07-22</release-date>
    </article>
</articles>

I want get the value of the first id of the Author with id = 1 .

For this I have created a step using content modififier and I am creating a property called author , source type XPATH and Source Value /articles.article[0].author.author

However this not work,

How can get this value and storage in the variable author and firstname?

Name: author

Source Type: XPath

Source Value : /articles.article[0].author.id

Name: firstname

Source Type: XPath

Source Value : /articles.article[0].author.firstname

Regards

View Entire Topic
Sriprasadsbhat
Active Contributor

Hello Party,

Below will give desired output.

/articles/article[1]/author[@id = '1']/firstname/text()

Regards,

Sriprasad Shivaram Bhat

former_member740482
Participant
0 Likes

Hi sriprasadshivaramabhat

  1. With source value: /articles/article[1]/author[@id = '1']/firstname/text()

Output.

2. With source value: /articles/article[1]/author[@id = '1']/text()

Output.

3. With source value: /articles/article[1]/author[@id = '1']

NameValue: author

value: Siena Kerr

How can get the value of the attribute id? ie 1 for this case