No announcement yet.
  • Filter
  • Time
Clear All
new posts

  • valueXpath returns only the first record in json array

    I have a DS XML with a field with valueXpath attribute. It looks like this
    <field name="tag" valueXpath="tags/tagNames"/>

    Following is a sample json data I get from backend
    affectedRows: 0,
    data: [{
    tags: [{
    tagName: "tag1"
    tagName: "tag2"
    lastName: "lastName",
    updatedBy: null,
    roles: [4],
    updatedDate: new Date(946684800000),
    userName: "myusername",
    firstName: "SJ",
    companyId: "cid",
    createdDate: new Date(946684800000),
    createdBy: null,
    phone: "unknown",
    email: "",
    status: "open"

    valueXpath specified gives me only the first tagName ie tag1. How do i get an array of all tagNames? I want something like ["tag1","tag2"]
    I have tried all different xpath combinations
    - tags[*].tagName
    - tags//tagName
    - tags[*]/tagName
    - tags[*]//tagName

    In all instances I either get 1 or 0 but never all.
    There is a similar thread from long time ago
    that is exactly describes my issue.
    Is this still a problem?


  • #2
    If you read the docs for valueXPath and specifically the link to XMLTool.selectObjects() you can see that support for aggregating properties across multiple objects isn't there. But you can use DataSource.transformResponse() to do this transform if you want.