get data stored in xml of pdf-form itself at the runtime

nikg-fh

19-04-2011

Hello,

I generate a pdf form with some data includet e.g. firstname = dave. personID = 12345.

all this data (import-parameter is a table) is "stored" in the xml of my form:

<?xml version="1.0" encoding="UTF-8"?>
<xfa:data xmlns:xfa="
http://www.xfa.org/schema/xfa-data/1.0/">

   <data>

      <IF_TABLE_PERSON>

           <DATA xfa:dataNode="dataGroup">

                <FIRSTNAME>Dave</RFIRSTNAME>

               <PERSONID>12345</PERSONID>

firstname is binded to a textfield therefore there is no problem to get it.

because it is a table i could get the value in several ways:

a) myFirstNameField.rawValue;

b) this.resolveNode("$record.IF_TABLE_PERSON.DATA[1]").FIRSTNAME.value;

The PartnerID must not be binded anywhere (no hidden fields!). The question is, how do i get the value of PERSONID directly from xml?

xfa.datasests.data ..... ????

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

pguerett

19-04-2011

Looks like you have an extra data node in there .....try building the expression one piece at a time

Start with app.alert(xfa.datasets.data.data.saveXML("pretty"))

Onceyou get that then add the next node app.alert(xfa.datasets.data.data.IF_TABLE_PERSON.saveXML("pretty"))

Continue until you get to the actual node you want.

Paul

Answers (7)

Answers (7)

pguerett

19-04-2011

The saveXML is only used if the node has child nodes. In the case of PERSONID then you want the value of the node and woudl use the value property.

In the case of repeating nodes liek you have you woudl use occurance numbers or change your tactic all together and use E4X. The expression in E4X are much easier and more powerful to use. I have included an example of using E4X to get to repeating nodes.

Paul

pguerett

19-04-2011

xfa.dataset.data will give you the root of the data dom. I suggest that you put a large multiline filed on the form (this is for debug only) and you can see the structure of the dom in that field. Use this command to populate the field:

FieldName.rawValue = xfa.datasets.data.saveXML("pretty");

Now that you can see the structure you can navigate your way to the PERSONID node and grab the value.

something like this:

xfa.dataset.data.IF_TABL_PERSON.DATA.PERSONID.value

Remember it is the value property you want and not the rawValue for nodes in the dom.

Hope that helps

Paul

gevanj

11-02-2020

Hi,

Its working... Thanks Lot

 

Its like this:

-<V_ZFP_TABLE>


-<DATA xfa:dataNode="dataGroup" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">

<NAME1_X>Helmerich & Payne Internationa</NAME1_X>

<KUNNR_X>qwdqwd</KUNNR_X>

</DATA>


-<DATA xfa:dataNode="dataGroup" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">

<NAME1_X>Latif Brothers</NAME1_X>

<KUNNR_X>qwdq</KUNNR_X>

</DATA>

 

------------------------------------------------------------

REPLACE ALL OCCURRENCES OF  '<DATA xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:dataNode="dataGroup">'
 IN lv_xml_data_string
 WITH '<item>'.

REPLACE ALL OCCURRENCES OF  '</DATA>'
 IN lv_xml_data_string
 WITH '</item>'.

geekFirst77

28-08-2013

Hi,

Could you please let me know how to delete the node say (DATA[1]) from the XML above and copy the manipulated XML back into some text field?

Thanks.

nikg-fh

19-04-2011

Just one more question to get it right:

<xfa:data xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">
   <data>
      <IF_TABLE_PERSON>
         <DATA>
            <FIRSTNAME/>
            <PERSONID>
          </DATA>

         <DATA>
            <FIRSTNAME/>
            <PERSONID>
          </DATA>

          ......

      </IF_TABLE_PERSON>

In case I want to get the content of IF_TABLE_PERSON -Tag I use xfa.datasets.data.data.IF_TABLE_PERSON.saveXML("pretty");

I have tried to get through to PERSONID like this:

xfa.datasets.data.data.IF_TABLE_PERSON.PERSONID.saveXML("pretty");  ---- it is undefined, because it is inside another DATA-tag and there are several of them

So I have to use something like an array?!

xfa.datasets.data.data.IF_TABLE_PERSON[1].PERSONID.saveXML("pretty");    --- doesn't work either

What is the correct way to "loop" trough the schema in this case?

nikg-fh

19-04-2011

thank you for the fast reply.

I have already tried your solution (http://forums.adobe.com/thread/341785?tstart=-2)  ; ))

the xml-schema I posted above is from that field I placed on the form for debuging purpose.

The problem is, that javascript does not recognize the "nodes" of xml:

TypeError: xfa.datasets.data.IF_TABLE_PERSON.PERSONID.VALUE is undefined

what am I doing wrong?