Highlighted

Get value using xpath

alukyro

01-12-2008

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

Replies

Highlighted

aoatak

02-12-2008

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
Highlighted

alukyro

03-12-2008

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
Highlighted

pguerett

04-12-2008

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.
Highlighted

alukyro

05-12-2008

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
Highlighted