# Scan QR code and populate details in a form

**URL:** <https://forum.getodk.org/t/scan-qr-code-and-populate-details-in-a-form/14438>\
**Category:** Support\
**Created:** [August 7, 2018, 9:59am UTC](https://forum.getodk.org/t/scan-qr-code-and-populate-details-in-a-form/14438 "2018-08-07T09:59:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bala](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/b/94ad74/32.png) [@bala](https://forum.getodk.org/u/bala)\
**Post date:** [August 7, 2018, 9:59am UTC](https://forum.getodk.org/t/scan-qr-code-and-populate-details-in-a-form/14438/1 "2018-08-07T09:59:01Z")

</div>

Hi

I am using ODK collect to scan a QR code. I created a form that uses barcode to scan. issue is an xml is getting created, is there a way i can get the values populated in a form. can someone provide me a sample form. I am using motoe3 power and odk collect v1.16.1

---

<div class="post-metadata">

**Author:** ![danbjoseph](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/danbjoseph/32/21901_2.png) [@danbjoseph](https://forum.getodk.org/u/danbjoseph)\
**Post date:** [August 7, 2018, 5:36pm UTC](https://forum.getodk.org/t/scan-qr-code-and-populate-details-in-a-form/14438/2 "2018-08-07T17:36:04Z")

</div>

You are using a `barcode` [type question](http://xlsform.org/en/#question-types)?  
The value populated in the form will depend on the QR code and not ODK.  
For instance, I used [https://www.qr-code-generator.com/#text](https://www.qr-code-generator.com/#text) to create codes for  
`doge` and `danbjoseph`  
 ![doge](https://getodk.b-cdn.net/uploads/default/original/2X/a/a992cb920d098913159ee621ee5ed2dae0f589a6.png) &nbsp;&nbsp; ![danbjoseph](https://getodk.b-cdn.net/uploads/default/original/2X/6/688d88e697620bacfeb22291d148084d41aaf4d8.png)

 ![Screenshot_20180807-125533](https://getodk.b-cdn.net/uploads/default/original/2X/4/4681d76bcf932d47c350db2a72eb97ca50a21753.png) ![Screenshot_20180807-125627](https://getodk.b-cdn.net/uploads/default/original/2X/d/d7f9069261dbabc1835b8c3bc3514e255bfdc76c.jpg) ![Screenshot_20180807-125551](https://getodk.b-cdn.net/uploads/default/original/2X/6/6f68f3a60068f58019781fece6beb2ff62ef6ce4.png)

I'm not sure I understand your note about:

> an xml is getting created

Can you give more details about your question?

---

<div class="post-metadata">

**Author:** ![bala](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/b/94ad74/32.png) [@bala](https://forum.getodk.org/u/bala)\
**Post date:** [August 8, 2018, 1:23am UTC](https://forum.getodk.org/t/scan-qr-code-and-populate-details-in-a-form/14438/3 "2018-08-08T01:23:41Z")

</div>

Thanks for reply. when i scan the QRcode, the output is displaying as an xml. how to get this xml populated into some labels like name,date of birth etc.

---

<div class="post-metadata">

**Author:** ![Xiphware](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/xiphware/32/2587_2.png) [@Xiphware](https://forum.getodk.org/u/Xiphware)\
**Post date:** [August 8, 2018, 2:54am UTC](https://forum.getodk.org/t/scan-qr-code-and-populate-details-in-a-form/14438/4 "2018-08-08T02:54:48Z")

</div>

What is the XML that you are getting? Or better yet, can you perhaps just post the QR code. I suspect its simply the fact the QR code you are scanning has 'encoded' a string that just happens to be XML in the first place, in which case there's no a whole lot Collect can do about it... AFAIK the [barcode widget](https://docs.opendatakit.org/form-question-types/#barcode-widget) doesn't subsequently try to parse the string/text it captured to determine whether its XML, JSON, YAML... and decipher it further.

---

<div class="post-metadata">

**Author:** ![LN](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/ln/32/1605_2.png) [@LN](https://forum.getodk.org/u/LN)\
**Post date:** [August 8, 2018, 2:28pm UTC](https://forum.getodk.org/t/scan-qr-code-and-populate-details-in-a-form/14438/5 "2018-08-08T14:28:42Z")

</div>

Are you trying to pull out values from a QR code and assign them to different fields?

One way to do this is to separate the values in the QR code with spaces and to use the `selected` function. Take a look at the second form posted at [Steps of printing barcode and auto fill the for by scanning barcode and continue updating another form - #9 by LN](https://forum.getodk.org/t/steps-of-printing-barcode-and-auto-fill-the-for-by-scanning-barcode-and-continue-updating-another-form/10786/9) for an example. You should be able to try it out with the barcode provided in the message and see whether it's what you're looking for.

---

<div class="post-metadata">

**Author:** ![Wildscapes](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/wildscapes/32/10337_2.png) [@Wildscapes](https://forum.getodk.org/u/Wildscapes)\
**Post date:** [February 10, 2020, 10:13pm UTC](https://forum.getodk.org/t/scan-qr-code-and-populate-details-in-a-form/14438/6 "2020-02-10T22:13:40Z")

</div>

Hi, I know this is a old post but could you just confirm if you could use a different character to separate the text, like \_ (underscore) or -??? Does it have to be a space?

---

<div class="post-metadata">

**Author:** ![Xiphware](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/xiphware/32/2587_2.png) [@Xiphware](https://forum.getodk.org/u/Xiphware)\
**Post date:** [February 10, 2020, 10:31pm UTC](https://forum.getodk.org/t/scan-qr-code-and-populate-details-in-a-form/14438/7 "2020-02-10T22:31:38Z")

</div>

[selected()](https://docs.opendatakit.org/form-operators-functions/#selected) function _requires_ space separated string.

[see [https://github.com/opendatakit/javarosa/blob/master/src/main/java/org/javarosa/xpath/expr/XPathFuncExpr.java](https://github.com/opendatakit/javarosa/blob/master/src/main/java/org/javarosa/xpath/expr/XPathFuncExpr.java) line 1018 for the gory details...]
