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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Get value using xpath

alukyro
Level 3
Level 3
Hi,



I'm prepopulating my form with xml. I need to access some elements in this xml (get the value of) using javascript and xpath.



Anybody know how that can be done, please?



Kind regars



Lars
0 Replies
aoatak
Level 4
Level 4
Hi Lars,

Would you like to get the field values within your process? If so, it depends on your process variable type:



-If it xfaform, you can directly use xpath (you should know the xml schema if you did not embedded in the form)



-If it is a DocumentForm then you can extract its data into XML using Form Data Integration services. From the XML data you can still get the values using XPATH



Oguz

http://www.kgc.com.tr
alukyro
Level 3
Level 3
Hi Oguz,



Thanks for your reply. What I need to do is make the xpath calls in Designer on my dataconnection, rather than in Workbench.



In the LiveCycle Designer I have attached an xsd as datasource. I would like to implement some logic in this form using xpath and javascript. For example make an xpath that counts the number of a given element or extract values from the incoming xml.



Thanks



Lars
pguerett
Level 10
Level 10
You do not need xpath .....you have access to the data dom that is loaded in the form. To access it use xfa.datasets.data. This will give you access to the root node. You can path through al nodes to get to the one you want from there. I like to see the structure I am working with so I create a multiline field on the form and use this command to see the DOM Fieldname.rawValue = xaf.datasets.data.saveXML("pretty");



This will dump the DOM into that field so you can visually see it. Then you can simply path your way to the node that you want.



If you want the value of a node use the value command and not rawValue. There is also a nodes command that will return multiple nodes as well. Play with it and see if it does what you want.
alukyro
Level 3
Level 3
Thanks Paul,



I tried creating the multiline field to see the DOM - worked great 🙂



In regards to the path to nodes, I do this right from xfa.datasets.data? Like for example: "xfa.datasets.data.Application.Applicant.value" (If I wanted the value under Applicant)



Thanks again
pguerett
Level 10
Level 10
yes .....notice that it will follow the heirarchy of the form or the schema if there is one present.