Having problems creating an array from XML data in Acrobat Javascript, please help if you can

Posted by Kevin Minke on Stack Overflow See other posts from Stack Overflow or by Kevin Minke
Published on 2009-08-27T18:06:19Z Indexed on 2010/06/05 18:02 UTC
Read the original article Hit count: 229

Filed under:
|
|
|

I have a manually created array that already works example below:

var PartsData = { 179: { ref:"",
                         partNum: "201-2007-C00-00",
                         descript: "System Monitor Card (Tracewell Only)",
                         cage: "39764",
                         qty: "1",
                         SMR: "XBOZZ",
                         UOC: "A" }};

Now this array above is is just one value in the array and it works fine. Here is the XML that I am trying to use to dynamically change the values.

  <?xml version="1.0" encoding="utf-8"?>
  <partsTables>
    <partsList>
      <part sheetNum="ta1">
        <breakDownIndexNo>-1 </breakDownIndexNo>
        <referenceDesg/>
        <indent>20534220P01 </indent>
        <description/>
        <cage>TAC RI, GRADE-A SHOCK (TEC RACK), ALT P/N 72304-1</cage>
        <qtyPerAssy>23991 </qtyPerAssy>
        <smr>1 </smr>
        <uoc>ADODD </uoc>
        <blank/>
      </part>
    </partsList>
  </partsTables>

I have this parsing just fine in Acrobat. Now I want to make the array work for me in using these values. if I have the following below it will work.

Where part.item(i).indent.value equals the value of the indent node, etc.

newArr = { 179: { 
                    ref: part.item(i).referenceDesg.value,
                    partNum: part.item(i).indent.value,
                    descript: part.item(i).cage.value,
                    cage: part.item(i).qtyPerAssy.value,
                    qty: part.item(i).smr.value,
                    SMR: part.item(i).uoc.value,
                    UOC: part.item(i).blank.value}};

As soon as I try to make the 179 value, which is in the breakDownIndexNo node, dynamic by using the direct part.item(i).breakDownIndexNo.value it will not compile. Acrobat is using javascript so I'm not sure why I can not get this to parse.

I have tried to create a variable out of the breakDownIndexNo node and typed it to both a String and an Integer. this will let it create the array but it will not let me output from the array. newArr[indexNum].partNum gives me "no properties" where newArr[179].partNum if I were to manually set the index number to 179 will print out the value of part.item(i).indent.value.

If any of you have an idea or an answer please let me know.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about Xml