# How to extract a value attribute from an input tag where the body is a web page?

**URL:** <https://community.postman.com/t/how-to-extract-a-value-attribute-from-an-input-tag-where-the-body-is-a-web-page/1535>\
**Category:** Help Hub\
**Created:** [May 3, 2018, 8:54am UTC](https://community.postman.com/t/how-to-extract-a-value-attribute-from-an-input-tag-where-the-body-is-a-web-page/1535 "2018-05-03T08:54:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![davout\_uk](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@davout\_uk](https://community.postman.com/u/davout_uk)\
**Post date:** [May 3, 2018, 8:54am UTC](https://community.postman.com/t/how-to-extract-a-value-attribute-from-an-input-tag-where-the-body-is-a-web-page/1535/1 "2018-05-03T08:54:44Z")

</div>

I’m running a GET call to return a web page as body  
I want to extract the value attribute of a named ‘input’ tag from the XML body.  
Any suggestions on how to do this?  
TIA

---

<div class="post-metadata">

**Author:** ![deepak.pathania](https://avatars.discourse-cdn.com/v4/letter/d/50afbb/32.png) [@deepak.pathania](https://community.postman.com/u/deepak.pathania)\
**Post date:** [May 3, 2018, 11:21am UTC](https://community.postman.com/t/how-to-extract-a-value-attribute-from-an-input-tag-where-the-body-is-a-web-page/1535/2 "2018-05-03T11:21:19Z")

</div>

Hey @davout_uk. Can you help me understand the use case better?  
From what I know so far, you are trying to parse an XML response from a GET request to get a particular value. Here’s how you can do that.

The `pm.reponse` API does not have a `.xml()` method to parse XML responses directly, you can read more about the API [here](https://www.getpostman.com/docs/v6/postman/scripts/postman_sandbox_api_reference). To do so, you’ll need to use one of the built-in library modules, called xml2js. Your test script would look something like.

```javascript
var parseString = require('xml2js').parseString;

parseString(pm.response.text(), function (err, result) {
    pm.globals.set("xml_parsed_response", JSON.stringify(result));
});

```

Now that you have the parsed XML response stored as a global variable, you can access it in the subsequent request using `pm.globals.get("xml_parsed_response");` and access the required key using the dot notation.

Remember that `parseString` is an asynchronous function and you’ll have to set the result to a global/environment variable to access it in subsequent requests.

Feel free to reach out in case this wasn’t your exact query or if you need additional help.

---

<div class="post-metadata">

**Author:** ![vdespa](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/vdespa/32/2770_2.png) [@vdespa](https://community.postman.com/u/vdespa)\
**Post date:** [May 4, 2018, 6:01pm UTC](https://community.postman.com/t/how-to-extract-a-value-attribute-from-an-input-tag-where-the-body-is-a-web-page/1535/3 "2018-05-04T18:01:20Z")

</div>

It sounds like you are interested in parsing HTML and not XML.

It that is the case, I would suggest looking into the cheerio library.

I have done a tutorial on how to use cheerio in this video: [https://youtu.be/B4ilccLUQVs](https://youtu.be/B4ilccLUQVs)

Otherwise please clarify the questions, as @deepak.pathania suggested.

---

<div class="post-metadata">

**Author:** ![mafi81](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@mafi81](https://community.postman.com/u/mafi81)\
**Post date:** [September 6, 2018, 10:20am UTC](https://community.postman.com/t/how-to-extract-a-value-attribute-from-an-input-tag-where-the-body-is-a-web-page/1535/4 "2018-09-06T10:20:30Z")

</div>

Thanks vdespa, you helped me solving my problem.  
regards
