LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  Enrich Structure Data from XML file with filename

    Employee
    Posted 02-23-2015 03:56

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: cristi.boizas

    Hi guys,

    Another question, is there a way which to enrich the structure output of an XML Data node ( lal1 library) with the filename it was extracted from?
    I need to read multiple XML files and some of them may have erroneous structures ( missing some nodes or different node definition or etc... ), the problem is that when I read 2 or more files I obtain an unified structure on the output of the XML Data Node and I need it separated per filename.

    Also, can I include the filename in the Metadata of the ouput pin Data? I mean if I have a file test.xml containing <Country><City></City></Country> I would like to have the output like this:
    filename.Country filename.Country.City ?

    Thanks,

    Cristi.


  • 2.  RE: Enrich Structure Data from XML file with filename

    Employee
    Posted 02-24-2015 10:53

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ryeh

    The following might be a bit overkill, but it does the job. The most complex part is using the looping example from Ernest.

    In short, we read in all files with *.xml extension from a folder. We then use the XML Data node to read in the data per file. Because the filename isn't an optional output, we need to merge that back in with the data from the XML Data node. And last step is to create a new field containing all the fields.
    Attachments:
    XML.zip


  • 3.  RE: Enrich Structure Data from XML file with filename

    Employee
    Posted 02-24-2015 11:07

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Tim Meagher

    			
    				Because the filename isn't an optional output, we need to merge that back in with the data from the XML Data node.
    			
    
    For that you can use the PassThroughFields parameter on the node in the Optional tab.

    Tim.


  • 4.  RE: Enrich Structure Data from XML file with filename

    Employee
    Posted 02-27-2015 06:31

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ryeh

    Shaking my head at myself. Thanks, Tim. Totally missed that. I've posted an updated (much simpler) version.
    Attachments:
    readXML_v2.zip


  • 5.  RE: Enrich Structure Data from XML file with filename

    Employee
    Posted 03-03-2015 04:34

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: cristi.boizas

    Thanks guys, I initially solved this using shell script and adding a new tag on the lowest level with the file name.

    Since you seem to know you way well with parsing XML files with the BRE , I would ask you 2 more questions:

    1. When I have a tag which contains only null values in all the file e.g <Country><Country> , the XML data node doesn't recognize this tag in the structure output of it . Any way around this ( this is also currently solved by me adding by shell script in a temp file "@NULL" where tags contain empty data, but I would like to do it using the functionality of the BRE application)?
    2. The XML files I have to work can have null values for some tags represented like this <Country />, again the XML Data node does not recognize this null value. Any solution for this?

    Thanks .

    Cristi.


  • 6.  RE: Enrich Structure Data from XML file with filename

    Employee
    Posted 03-03-2015 06:48

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ryeh

    Could you provide a sample? I just ran a quick test with null fields and it worked fine. Using <fieldName/> notation also worked.