Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

access xml-nodes from xml file

arthurf48713214
Level 3
Level 3

Hello,

how can i access a node of a xml-file

looks like this:

<RootNode>

     <EntryNode>

          <ColumnA>Some Value A</ColumnA>

          <ColumnB>Some Value B</ColumnB>

     </EntryNode>

     <EntryNode>

          <ColumnA>Some Value C</ColumnA>

          <ColumnB>Some Value D</ColumnB>

     </EntryNode>

</RootNode>

thanks for your help

1 Accepted Solution
_Bruce_Robertson
Correct answer by
Level 10
Level 10

Hi,

I'm guessing you mean reference it in JavaScript code rather than binding a field to it and using the rawValue?

In JavaScript $data is a reference to the Data DOM, so

$data.resolveNode('RootNode')                                                                 // refers to your root node
$data.resolveNodes('RootNode.EntryNode[*]').length                               // returns 2
$data.resolveNodes('RootNode.EntryNode[*].ColumnA').item(1).value    // returns "Some Value C"

Bruce

View solution in original post

4 Replies
_Bruce_Robertson
Correct answer by
Level 10
Level 10

Hi,

I'm guessing you mean reference it in JavaScript code rather than binding a field to it and using the rawValue?

In JavaScript $data is a reference to the Data DOM, so

$data.resolveNode('RootNode')                                                                 // refers to your root node
$data.resolveNodes('RootNode.EntryNode[*]').length                               // returns 2
$data.resolveNodes('RootNode.EntryNode[*].ColumnA').item(1).value    // returns "Some Value C"

Bruce

View solution in original post

arthurf48713214
Level 3
Level 3

Thanks so much bruce.

I have another problem.

<RootNode>

     <EntryNode>

          <ColumnA>Some Value A</ColumnA>

          <ColumnB>Some Value B</ColumnB>

     </EntryNode>

</RootNode>

$data.resolveNodes('RootNode.EntryNode[*]').length                               // it returns 1

<RootNode>

</RootNode>

$data.resolveNodes('RootNode.EntryNode[*]').length                               // it returns 1  why not 0

Arthur

_Bruce_Robertson
Level 10
Level 10

Do you have some fields bound to EntryNode or ColumnA, etc.  If so and they have a min occurs of 1 then an EntryNode will be created in the Data DOM.