Expand my Community achievements bar.

SOLVED

access xml-nodes from xml file

Avatar

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

Avatar

Correct answer by
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

Avatar

Correct answer by
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

Avatar

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

Avatar

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.