Results 1 to 4 of 4

Thread: Strategy for parsing complicated xml files with many children levels

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2009

    Default Strategy for parsing complicated xml files with many children levels

    I need to extract information from a xml file containing bank transaction data according to ISO20022. Some branches in that file are up to 9 generations deep. My question is how to parse that file, using namespace, in the smartest way. I normally prefer to use DF classes, but as far as I understand, that is much more complicated and time consuming than using Chilkat code in this case.

    Chilkat has a parsing tool which generates DF code, but that code uses the Chilkat classes. I tried to do a similar thing myself according to the DF help text but have more or less given that up. It seems to be too complicated. The last problem that stopped me was that I failed retrieving the information from the two AddtlRmtInf nodes in the attached picture. If it had been just one node, this had worked:

    Get FindNode of hoTxDtls "iso:RmtInf/iso:Strd" to hoStrd 
    Get ChildElementValueNS of hoStrd sNamespace "AddtlRmtInf" to sAddtlRmtInf
    But when there are several AddtlRmtInf nodes, something like this is needed:

    Get FindNode of hoTxDtls "iso:RmtInf/iso:Strd" to hoStrd  
    Integer iAddtlRmtItems k 
    Get FindNodeList of hoStrd "iso:AddtlRmtInf" to hoAddtlRmtList  
    Get NodeListLength of hoAddtlRmtList to iAddtlRmtItems                  
    Decrement iAddtlRmtItems
    For k from 0 to iAddtlRmtItems
         Get CollectionNode of hoAddtlRmtList k to hoAddtlRmtInf
    //     Get ChildElementValueNS hoAddtlRmtInf sNamespace " AddtlRmtInf" to sCdtrRefInf  // Does not work. It is not the childelement value but the element value that should be retrieved.
    //     Get elementValueNS hoAddtlRmtInf sNamespace " AddtlRmtInf" to sCdtrRefInf  // This function doesn’t exist
          Writeln  sAddtlRmtInf
          Send Destroy of hoAddtlRmtInf
    There must be a function in DF that can be used for retrieving the text from a node itself, not the child node. But what function?

    With Chilkat, this information can be retrieved with:

    Move 0 to k
    Get ComNumChildrenHavingTag of hoXml "BkToCstmrStmt|Stmt|Ntry[i]|NtryDtls|TxDtls[j]|RmtInf|Strd|AddtlRmtInf" to iCount_k
    While (k < iCount_k)
         Set ComK of hoXml to k
         Get ComGetChildContent of hoXml "BkToCstmrStmt|Stmt|Ntry[i]|NtryDtls|TxDtls[j]|RmtInf|Strd|AddtlRmtInf[k]" to sAddtlRmtInf
         Show sAddtlRmtInf "   "
         Move (k + 1) to k
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	ISO20022xml.jpg 
Views:	17 
Size:	217.7 KB 
ID:	16848  

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts