# Help me to remove span tag using xpath

**URL:** <https://onehack.st/t/help-me-to-remove-span-tag-using-xpath/92601>\
**Category:** Discussion & Solutions\
**Tags:** solved\
**Created:** [June 18, 2020, 8:55am UTC](https://onehack.st/t/help-me-to-remove-span-tag-using-xpath/92601 "2020-06-18T08:55:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![indurani](https://onehack.st/user_avatar/onehack.st/indurani/32/11305_2.png) [@indurani](https://onehack.st/u/indurani)\
**Post date:** [June 18, 2020, 8:55am UTC](https://onehack.st/t/help-me-to-remove-span-tag-using-xpath/92601/1 "2020-06-18T08:55:37Z")

</div>

```
<h1>
        <span>first text</span><br class="myclass">
	second text
    </h1>

```

Xpath : //html/body/section/section/div/article/div[3]/h1

result :first text second text

What i need : second text

not working i tried ://html/body/section/section/div/article/div[3]/h1/text()

How to achieve this ??

please help me urgent

---

<div class="post-metadata">

**Author:** ![Alexe\_John](https://onehack.st/user_avatar/onehack.st/alexe_john/32/8315_2.png) [@Alexe\_John](https://onehack.st/u/Alexe_John)\
**Post date:** [June 19, 2020, 12:41pm UTC](https://onehack.st/t/help-me-to-remove-span-tag-using-xpath/92601/2 "2020-06-19T12:41:18Z")

</div>

> [@indurani](#):
>
> ```auto
> <h1>
> <span>first text</span><br class="myclass">
> second text
> </h1>
> 
> ```

Try this:

//h1/text()[preceding-sibling::br]

---

<div class="post-metadata">

**Author:** ![indurani](https://onehack.st/user_avatar/onehack.st/indurani/32/11305_2.png) [@indurani](https://onehack.st/u/indurani)\
**Post date:** [June 19, 2020, 1:29pm UTC](https://onehack.st/t/help-me-to-remove-span-tag-using-xpath/92601/3 "2020-06-19T13:29:15Z")

</div>

> [@Alexe\_John](#):
>
> //h1/text()[preceding-sibling::br]

big thanks. its working
