XPATH getting text inside balise that contains balise which contains text












0















My html :



<div class="my class">
<p style="padding:3px;">
<b> Série :</b>
my text I need to got with my xpath expression
</p>


For now I have : '//div[@class="my class"]/p[b[contains(., 'Série :')]]' But the last part with the contains isn't working. I really need to say that i want the text from a balise p that contains balise b which contains text "Serie" because there is an other structures like that with the only difference being the text in that famous balise.










share|improve this question

























  • Your b tag is not correct. Do you mean <b> Série :</b>? Also your XPath should have extra closing square bracket

    – Andersson
    Nov 12 '18 at 14:26











  • Yeah I forgot the ">" and also one "]" my bad it's edited.

    – Ayra
    Nov 12 '18 at 14:27











  • What is the point of escaping single quotes if you can just use double quotes contains(., "Série :")?

    – Andersson
    Nov 12 '18 at 14:30











  • It's the same. I choose to escape but yesi could have used double quotes

    – Ayra
    Nov 12 '18 at 14:31











  • XPath seem to be correct. Can you elaborate a little about the last part with the contains isn't working? How do you use your XPath? Share your current code and current output

    – Andersson
    Nov 12 '18 at 14:33
















0















My html :



<div class="my class">
<p style="padding:3px;">
<b> Série :</b>
my text I need to got with my xpath expression
</p>


For now I have : '//div[@class="my class"]/p[b[contains(., 'Série :')]]' But the last part with the contains isn't working. I really need to say that i want the text from a balise p that contains balise b which contains text "Serie" because there is an other structures like that with the only difference being the text in that famous balise.










share|improve this question

























  • Your b tag is not correct. Do you mean <b> Série :</b>? Also your XPath should have extra closing square bracket

    – Andersson
    Nov 12 '18 at 14:26











  • Yeah I forgot the ">" and also one "]" my bad it's edited.

    – Ayra
    Nov 12 '18 at 14:27











  • What is the point of escaping single quotes if you can just use double quotes contains(., "Série :")?

    – Andersson
    Nov 12 '18 at 14:30











  • It's the same. I choose to escape but yesi could have used double quotes

    – Ayra
    Nov 12 '18 at 14:31











  • XPath seem to be correct. Can you elaborate a little about the last part with the contains isn't working? How do you use your XPath? Share your current code and current output

    – Andersson
    Nov 12 '18 at 14:33














0












0








0








My html :



<div class="my class">
<p style="padding:3px;">
<b> Série :</b>
my text I need to got with my xpath expression
</p>


For now I have : '//div[@class="my class"]/p[b[contains(., 'Série :')]]' But the last part with the contains isn't working. I really need to say that i want the text from a balise p that contains balise b which contains text "Serie" because there is an other structures like that with the only difference being the text in that famous balise.










share|improve this question
















My html :



<div class="my class">
<p style="padding:3px;">
<b> Série :</b>
my text I need to got with my xpath expression
</p>


For now I have : '//div[@class="my class"]/p[b[contains(., 'Série :')]]' But the last part with the contains isn't working. I really need to say that i want the text from a balise p that contains balise b which contains text "Serie" because there is an other structures like that with the only difference being the text in that famous balise.







html xpath






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 '18 at 14:28









Andersson

37.6k103266




37.6k103266










asked Nov 12 '18 at 14:23









AyraAyra

1549




1549













  • Your b tag is not correct. Do you mean <b> Série :</b>? Also your XPath should have extra closing square bracket

    – Andersson
    Nov 12 '18 at 14:26











  • Yeah I forgot the ">" and also one "]" my bad it's edited.

    – Ayra
    Nov 12 '18 at 14:27











  • What is the point of escaping single quotes if you can just use double quotes contains(., "Série :")?

    – Andersson
    Nov 12 '18 at 14:30











  • It's the same. I choose to escape but yesi could have used double quotes

    – Ayra
    Nov 12 '18 at 14:31











  • XPath seem to be correct. Can you elaborate a little about the last part with the contains isn't working? How do you use your XPath? Share your current code and current output

    – Andersson
    Nov 12 '18 at 14:33



















  • Your b tag is not correct. Do you mean <b> Série :</b>? Also your XPath should have extra closing square bracket

    – Andersson
    Nov 12 '18 at 14:26











  • Yeah I forgot the ">" and also one "]" my bad it's edited.

    – Ayra
    Nov 12 '18 at 14:27











  • What is the point of escaping single quotes if you can just use double quotes contains(., "Série :")?

    – Andersson
    Nov 12 '18 at 14:30











  • It's the same. I choose to escape but yesi could have used double quotes

    – Ayra
    Nov 12 '18 at 14:31











  • XPath seem to be correct. Can you elaborate a little about the last part with the contains isn't working? How do you use your XPath? Share your current code and current output

    – Andersson
    Nov 12 '18 at 14:33

















Your b tag is not correct. Do you mean <b> Série :</b>? Also your XPath should have extra closing square bracket

– Andersson
Nov 12 '18 at 14:26





Your b tag is not correct. Do you mean <b> Série :</b>? Also your XPath should have extra closing square bracket

– Andersson
Nov 12 '18 at 14:26













Yeah I forgot the ">" and also one "]" my bad it's edited.

– Ayra
Nov 12 '18 at 14:27





Yeah I forgot the ">" and also one "]" my bad it's edited.

– Ayra
Nov 12 '18 at 14:27













What is the point of escaping single quotes if you can just use double quotes contains(., "Série :")?

– Andersson
Nov 12 '18 at 14:30





What is the point of escaping single quotes if you can just use double quotes contains(., "Série :")?

– Andersson
Nov 12 '18 at 14:30













It's the same. I choose to escape but yesi could have used double quotes

– Ayra
Nov 12 '18 at 14:31





It's the same. I choose to escape but yesi could have used double quotes

– Ayra
Nov 12 '18 at 14:31













XPath seem to be correct. Can you elaborate a little about the last part with the contains isn't working? How do you use your XPath? Share your current code and current output

– Andersson
Nov 12 '18 at 14:33





XPath seem to be correct. Can you elaborate a little about the last part with the contains isn't working? How do you use your XPath? Share your current code and current output

– Andersson
Nov 12 '18 at 14:33












1 Answer
1






active

oldest

votes


















0














To get only the text after the <b> tag, you can use an index on the text() node



//div[@class='my class']/p[contains(b, 'Série :')]/text()[2]


An alternative to this approach is using the following:: axis



//div[@class='my class']/p[contains(b, 'Série :')]/b/following::text()


Output in both cases is:



   my text I need to got with my xpath expression





share|improve this answer


























  • For information, the text I need to get back isn't in my balise b (she is closed) but in my balise p. I tried both ways and it still not working. result is none like my xpath won't find anything matching

    – Ayra
    Nov 12 '18 at 14:54











  • Thanks to your proposal and with some work on it, I managed to make it worked. Thanks :)

    – Ayra
    Nov 12 '18 at 15:14











  • xpath that worked : '//div[@class="pvo-pave-contenu"]/p[contains(b, "Série :")]/text()'

    – Ayra
    Nov 12 '18 at 15:15






  • 1





    That's interesting. Maybe your real file differs in some aspect from the sample, or your XPath program handles text() nodes differently. However, good that you found a solution that works.

    – zx485
    Nov 12 '18 at 15:17











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53264185%2fxpath-getting-text-inside-balise-that-contains-balise-which-contains-text%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














To get only the text after the <b> tag, you can use an index on the text() node



//div[@class='my class']/p[contains(b, 'Série :')]/text()[2]


An alternative to this approach is using the following:: axis



//div[@class='my class']/p[contains(b, 'Série :')]/b/following::text()


Output in both cases is:



   my text I need to got with my xpath expression





share|improve this answer


























  • For information, the text I need to get back isn't in my balise b (she is closed) but in my balise p. I tried both ways and it still not working. result is none like my xpath won't find anything matching

    – Ayra
    Nov 12 '18 at 14:54











  • Thanks to your proposal and with some work on it, I managed to make it worked. Thanks :)

    – Ayra
    Nov 12 '18 at 15:14











  • xpath that worked : '//div[@class="pvo-pave-contenu"]/p[contains(b, "Série :")]/text()'

    – Ayra
    Nov 12 '18 at 15:15






  • 1





    That's interesting. Maybe your real file differs in some aspect from the sample, or your XPath program handles text() nodes differently. However, good that you found a solution that works.

    – zx485
    Nov 12 '18 at 15:17
















0














To get only the text after the <b> tag, you can use an index on the text() node



//div[@class='my class']/p[contains(b, 'Série :')]/text()[2]


An alternative to this approach is using the following:: axis



//div[@class='my class']/p[contains(b, 'Série :')]/b/following::text()


Output in both cases is:



   my text I need to got with my xpath expression





share|improve this answer


























  • For information, the text I need to get back isn't in my balise b (she is closed) but in my balise p. I tried both ways and it still not working. result is none like my xpath won't find anything matching

    – Ayra
    Nov 12 '18 at 14:54











  • Thanks to your proposal and with some work on it, I managed to make it worked. Thanks :)

    – Ayra
    Nov 12 '18 at 15:14











  • xpath that worked : '//div[@class="pvo-pave-contenu"]/p[contains(b, "Série :")]/text()'

    – Ayra
    Nov 12 '18 at 15:15






  • 1





    That's interesting. Maybe your real file differs in some aspect from the sample, or your XPath program handles text() nodes differently. However, good that you found a solution that works.

    – zx485
    Nov 12 '18 at 15:17














0












0








0







To get only the text after the <b> tag, you can use an index on the text() node



//div[@class='my class']/p[contains(b, 'Série :')]/text()[2]


An alternative to this approach is using the following:: axis



//div[@class='my class']/p[contains(b, 'Série :')]/b/following::text()


Output in both cases is:



   my text I need to got with my xpath expression





share|improve this answer















To get only the text after the <b> tag, you can use an index on the text() node



//div[@class='my class']/p[contains(b, 'Série :')]/text()[2]


An alternative to this approach is using the following:: axis



//div[@class='my class']/p[contains(b, 'Série :')]/b/following::text()


Output in both cases is:



   my text I need to got with my xpath expression






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 12 '18 at 14:42

























answered Nov 12 '18 at 14:33









zx485zx485

13.6k122946




13.6k122946













  • For information, the text I need to get back isn't in my balise b (she is closed) but in my balise p. I tried both ways and it still not working. result is none like my xpath won't find anything matching

    – Ayra
    Nov 12 '18 at 14:54











  • Thanks to your proposal and with some work on it, I managed to make it worked. Thanks :)

    – Ayra
    Nov 12 '18 at 15:14











  • xpath that worked : '//div[@class="pvo-pave-contenu"]/p[contains(b, "Série :")]/text()'

    – Ayra
    Nov 12 '18 at 15:15






  • 1





    That's interesting. Maybe your real file differs in some aspect from the sample, or your XPath program handles text() nodes differently. However, good that you found a solution that works.

    – zx485
    Nov 12 '18 at 15:17



















  • For information, the text I need to get back isn't in my balise b (she is closed) but in my balise p. I tried both ways and it still not working. result is none like my xpath won't find anything matching

    – Ayra
    Nov 12 '18 at 14:54











  • Thanks to your proposal and with some work on it, I managed to make it worked. Thanks :)

    – Ayra
    Nov 12 '18 at 15:14











  • xpath that worked : '//div[@class="pvo-pave-contenu"]/p[contains(b, "Série :")]/text()'

    – Ayra
    Nov 12 '18 at 15:15






  • 1





    That's interesting. Maybe your real file differs in some aspect from the sample, or your XPath program handles text() nodes differently. However, good that you found a solution that works.

    – zx485
    Nov 12 '18 at 15:17

















For information, the text I need to get back isn't in my balise b (she is closed) but in my balise p. I tried both ways and it still not working. result is none like my xpath won't find anything matching

– Ayra
Nov 12 '18 at 14:54





For information, the text I need to get back isn't in my balise b (she is closed) but in my balise p. I tried both ways and it still not working. result is none like my xpath won't find anything matching

– Ayra
Nov 12 '18 at 14:54













Thanks to your proposal and with some work on it, I managed to make it worked. Thanks :)

– Ayra
Nov 12 '18 at 15:14





Thanks to your proposal and with some work on it, I managed to make it worked. Thanks :)

– Ayra
Nov 12 '18 at 15:14













xpath that worked : '//div[@class="pvo-pave-contenu"]/p[contains(b, "Série :")]/text()'

– Ayra
Nov 12 '18 at 15:15





xpath that worked : '//div[@class="pvo-pave-contenu"]/p[contains(b, "Série :")]/text()'

– Ayra
Nov 12 '18 at 15:15




1




1





That's interesting. Maybe your real file differs in some aspect from the sample, or your XPath program handles text() nodes differently. However, good that you found a solution that works.

– zx485
Nov 12 '18 at 15:17





That's interesting. Maybe your real file differs in some aspect from the sample, or your XPath program handles text() nodes differently. However, good that you found a solution that works.

– zx485
Nov 12 '18 at 15:17


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53264185%2fxpath-getting-text-inside-balise-that-contains-balise-which-contains-text%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Full-time equivalent

Bicuculline

さくらももこ