Please join your peers on either March 26 (8pm GMT) or March 28 (8am GMT) to watch as user extraordinaire and forum legend @"lindsay.stevens" demonstrates OpenClinica Insight.

See preview and register at

Insight makes it easy to ask questions of ALL of your clinical and operational data and visualize answers via interactive reports and dashboards. The idea is simple, but the results are powerful: ask your questions, choose your visualizations, then return often for updated, interactive results that link you to all of the underlying data.

Loading data from external XML file

I need to calculate a total strength, based upon the strength of a (selected) product and a (selected) volume.  The list of products could change, so I thought it would be useful to store the name / strength in an external XML file with the following format:
    <Product Code="001">
    <Product Code="002">
        <Description>Product 2</Description>

I am able to select the product names from the XML file, as described here :

However, having selected the relevant product name, I also want to retrieve the 'Strength' for the same product and load it into a second field on the CRF.  I have tried to do this by 're-reading' the same XML file, finding the relevant product (which is successfully selected into a separate item) and then extracting the Strength value.  I'm not sure if this is the best way to do this, and I can't get it to work anyway!

The following is the code I'm using to re-read the XML file.  This appears in the RIGHT_ITEM_TEXT for the 'Strength' Item.  Any thoughts / assistance would e gratefully received...

script src="//"></script>
<script lang="Javascript">
   jQuery(document).ready(function($) {
      var ProdList3Field = $("#ProdList3").parent().parent().find("select");
      var StrengthField = $("#Strength").parent().parent().find("input");
            type: "GET",
            url: "includes/productlist3.xml",
            dataType: "xml",
            success: function(xml){
                   if ($(this).find("Description").text() == ProdList3Field.val()) {
</script><span id="Strength"></span>


Best Answer


  • kristiakkristiak Posts: 1,281 ✭✭✭
    via Email
    I'm sure that XML-gurus like Gerben or Christian can help you!!

    Good luck!
  • billingibillingi Posts: 28

    Thanks for the brilliant suggestion!  I had already got the list part working, and I could return either the code or description or strength from the drop-down list, but I wanted all three!

    I ended up putting the 3 fields in the 'val()' of the code list, so that this additional information wasn't displayed in the list itself. The format I ended up using was "[001]Product 1{765}".  I was then able to use the javascript .indexOf() and .slice(<from>,<to>) to extract the relevant part of the val() string & out it into the relevant OpenClinica Items.

This discussion has been closed.