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

Doubt with XPath expression Using XML

former_member740482
Participant
0 Likes
891

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
former_member190293
Active Contributor
0 Likes

Hi! If you want to use some data from first element with id=1, you can use:

/articles.article[author/@id="1"][1]/...

Regards, Evgeniy.