Skip navigation
Currently Being Moderated

Parsing XML with Adobe Javascript

Feb 26, 2006 9:01 PM

I am using the standard SQL QPAC to fetch list data from a database. As we already know, the standard SQL APAC cannot retrieve multiple rows, but I use the "FOR XML AUTO" in my SQL statement so that all rows are returned in XML format.

I now only need to parse the XML and put the items into my drop-down list.

Does anyone have script samples that can parse XML from within LiveCycle? You would think that the capability exists since the product is based on xml/xfa.

Thanks,
Duncan Campbell
Xcellerate IT
 
Replies
  • Currently Being Moderated
    Feb 27, 2006 8:09 AM   in reply to (Duncan_Campbell)
    Are you looking to parse it in a script qpac? If so then you can store the XML in an xml process variable, then use getProcessDataValue() from PATExecutionContext to retrieve a Document object for the DOM.

    Chris
    Adobe Enterprise Developer Support
     
    |
    Mark as:
  • Currently Being Moderated
    Feb 28, 2006 8:47 PM   in reply to (Duncan_Campbell)
    Sure, take a look at the JavaDocs that come with the LiveCycle Workflow SDK. Under Documentation/api/LiveCycle_Workflow_SDK_API_Reference.

    FYI, in a script QPAC the PATExecutionContext is an implicit object accessed under patExecContext. In a custom QPAC it is a parameter to the execute method.

    Chris
    Adobe Enterprise Developer Support
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 1, 2006 12:47 AM   in reply to (Duncan_Campbell)
    Hi Duncan

    If you have problems doing it that way, you can also download our SQLPlus QPAC, which will allow you to iterate over a result set and format the output in a number of ways, including a simple comma separated list. You can then use a simple script in the form to unpack the list into a dropdown.

    Regards,
    Howard
    http://www.avoka.com
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 1, 2006 10:33 AM   in reply to (Duncan_Campbell)
    Duncan,

    It may be just as simple to write a QPAC that does the query and returns a comma-delimited list as a string. You could then have the form take that string as a hidden field and parse it into the drop-down list in the same method that Workflow provides the submission choice drop-down list.

    Clifton
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 1, 2006 10:34 AM   in reply to (Duncan_Campbell)
    heh, Howard typed faster. :)
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 2, 2006 7:58 AM   in reply to (Duncan_Campbell)
    You're getting an error because that XML is not well formed so a DOM cannot be built for it.  There needs to be a root node, something like enclosing all that in ....

    I'm attaching a simple workflow I exported.  It sets the value of an XML variable, and then using a script QPAC to call getProcessDataValue() and retrieve a Document object that can be used to parse the XML.

    Chris
    Adobe Enterprise Developer Support
     
    |
    Mark as:
  • Currently Being Moderated
    Aug 11, 2006 10:40 AM   in reply to (Duncan_Campbell)
    Duncan,

    Did you ever have any luck with this? Any additional pointers?

    I think I am going to do something similar. I am planning on sending in an email that contains XML data of just 9 fields (collected from a form online - outside of the LC system and then using the Email Receiver to collect the email. The email body is the XML data). So, I need to parse this out and set the elements to variables to populate my PDF form.

    If I get something working, I will try to post back.

    Thanks,
    Jennifer
     
    |
    Mark as:
  • Currently Being Moderated
    Aug 14, 2006 2:49 AM   in reply to (Duncan_Campbell)
    Hi Jennifer
    You may be able to get a fair bit of it done just using the SetValue QPAC. I think (although I'm not sure) that you can use expressions like:
    /process_data/myxml/rootnode/row[2]/firstname

    So as long as you know the number of rows you want to process, you may be able to get by.

    Let us know how you get on.

    howard
     
    |
    Mark as:
  • Currently Being Moderated
    Aug 23, 2006 4:39 PM   in reply to (Duncan_Campbell)
    Hello,

    Actually, I ended up doing something a little different.

    Since I only have 9 fields to get parse, I did use the Set Value QPAC, but I used substring-after and substring-before functions. I had to do this in two different Set Value QPACS, I couldn't group them together for some reason. So, the body of the email contains my XML data and I set the body to a variables and then parse it out in those 2 Set Value QPACS.

    It works great!

    -Jennifer
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 5, 2007 3:11 AM   in reply to (Duncan_Campbell)
    I could not able to retrieve the remote xml file(which means from server to another server) in Mozilla Firefox and some times inn IE also.
    I found the Error: "Error: uncaught exception: Permission denied to call method XMLDocument.load"

    please help me in this area if you find or knew.

    Thank you
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 5, 2007 3:18 AM   in reply to (Duncan_Campbell)
    Hi Thiru
    It's a little difficult to work out what you're doing from your posting.
    I suspect it may be that you're trying to load a document in Reader. This is not allowed, you must use Acrobat. (Or reader enable the form.)
    Howard
    http://www.avoka.com
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)