< class="prominent-subhead ">

Code Fix: Selecting data from XML Fields

This article has been archived, and/or refers to legacy products, components or features. The content in this article is offered "as is" and will no longer be updated. Archived content is provided for reference purposes only. This content does not infer that the product, component or feature is supported, or that the product, component or feature will continue to function as described herein.


Unexpected behavior may have been encountered at run time when retrieveing data from XML data fields under the following two (2) circumstances.

  • A node is located within a repeating group

    If the node is located within a repeating group, only the first item in the list will be selected. The remaining items in the repeating group are ignored.

  • An attribute with a namespace

    If the attribute has a namespace, then a null value was selected


To illustrate the unexpected behaviour, consider the following scenario. A group of users is contained within an XML document and the K2 Object Browser is used to select the repeating group containing the user details. However, at run time only one user is listed; selected from the repeating fields.

To better understand why this has occured, the following section of the article will describe how K2 Server has interpreted the XML document and what the limitations were. The XML code sample below illustrates how this took place.

    <User name="User1" email="User1@MyData.com"/>
    <User name="User2" email="User2@MyData.com"/>
    <User email="User3@MyData.com">User3</User>
    <User email="User4@MyData.com">User4</User>
Note: If an attribute had a namespace, then a null value would have been selected in all of the examples cited below.

Node: Users

  • If you select the *Name* attribute, User1 and User2 will be the destination users.
  • If you select the *User* node, blank users will be added because the inner text contains nothing.
Node: MoreUsers
  • If you select the *User* node, User3 and User4 will be the destination users because the inner text property contains those values.
  • If you select the *Email* attribute, the values User3@MyData.com and User4@MyData.com will be used.
Node: EvenMoreUsers
  • If you select the *User* node, the inner text will be selected and “flattened” out resulting in the values “User5@MyData.com” and “User6@MyData.com” – this is obviously not correct.
  • If you select the *Name* node underneath User node, only User5 will be the destination user.


Using a node that is nested within a repeating group will not result in a resolved list of users. Rather, this results in only the first user being selected or read from the repeating group and the remaining data is not identified as a list. The code sample below illustrates how the XML should be structured to form a user list in such a way that the K2 Server will be able to resolve the users.
Note: In the examples cited below, InfoPath may require the attribute to be included. Use option 1 as the preferred alternative.
//Option 1: The repeating group is not inside a repeating group


//Option 2: The attribute does not have a namespace


Error Resolution

This Hotfix is contained within the latest K2 blackpearl 0807 Update. Install the update package to resolve the error.

The latest K2 blackpearl 0807 Update is available as an independent installation package which can be found here: https://portal.k2.com/downloads/bp/default.aspx.