Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: DomNode selectbypath selectbyxpath using contains or starts-with  (Read 3692 times)
ORGA-SOFT B.
Posts: 34


« on: August 02, 2017, 09:41:13 am »

Hello @ all,

i'm trying to get all elements in the domnode that matches a string in the name tag.
So in xml i can do this with like this:

XPath  = //*[contains(@name, 'page_tab_')]
It selects all nodes that have the string page_tab_ inside the name

But when i try this at the function selectbypath of a domnode this doesn't work.

Here is my Code

   DEFINE   vlname      STRING,
            domtree     om.domnode,
            dmfieldlist om.nodelist,
            uiwin       ui.Window

   LET uiWin  = ui.WINDOW.getCurrent()
   LET domtree = uiWin.getNode()
   
   LET dmfieldlist = domtree.selectByPath("//*[contains(\"@name\", \"page_tab\")]")
   
   RETURN dmfieldlist

Hope someone can help me thanks a lot

Martin Stigmond
Reuben B.
Four Js
Posts: 965


« Reply #1 on: August 04, 2017, 01:56:50 am »

Hi Martin,

The om.DomNode.selectByPath has a limited syntax so as to support its intended use for finding nodes in the DOM tree.  So as per the documentation ...   http://4js.com/online_documentation/fjs-fgl-manual-html/#c_fgl_ClassDomNode_selectByPath.html ...and the example ... http://4js.com/online_documentation/fjs-fgl-manual-html/#c_fgl_ClassNodeList_example_2.html you just need to modify your clause to match what is given there.   

Something like (hopefully the slashes and quotes make it through to what you read)
Code
  1. domtree.selectByPath("//*[@name=\"page_tab\"]")

Historically I've wrapped it in a library function so I don't have to deal with the slashes and quotes each time when I call it!

Reuben






Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines