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

SOLVED

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

nikg-fh
Level 3
Level 3

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!

1 Accepted Solution
pguerett
Correct answer by
Level 10
Level 10

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

View solution in original post

8 Replies
pguerett
Level 10
Level 10

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

nikg-fh
Level 3
Level 3

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?

pguerett
Correct answer by
Level 10
Level 10

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

View solution in original post

nikg-fh
Level 3
Level 3

perfect!

it was: xfa.datasets.data.data.IF_TABLE_PERSON.PERSONID.value;

Thank you very much!

nikg-fh
Level 3
Level 3

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?

pguerett
Level 10
Level 10

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

geekFirst77
Level 2
Level 2

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.

gevanj
Level 1
Level 1

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