Icon

XML Easy Reader demo

Workflow to demonstrate reading an XML file WITHOUT using the XML Reader or XPath Nodes.

This workflow uses my XML Easy Reader component that is backed by a python script and uses cElementTree to read the XML file, and then generate a KNIME table from it. The only configuration required is to tell it what part of the XML file to look at.

Additionally further configuration can be performed by supplying a "column mapping" file, to enable you to restrict the columns to be output, and change their names. The basic file can first be generated by XML Easy Reader by processing the XML file, so you don't waste time and effort having to write it from scratch!

30th May 2021 @takbb Brian Bates

Owner with Pets Owner with Address Basic 2-d "table" - simplest format can beloaded without any configuration This example demonstrates a problemthat is resolved by the next example! This example demonstrates a problemthat is resolved by the next example! Node 3Unpack everythingremove grouping columnsremove grouping columnsUnpack everythingStraight unpack DOESN'T"fill down" !!Unpack top levelremove grouping columnsUnpack address so they "fill down"Unpack address so they "fill down"remove grouping columnsclear "empty" cellsUnpack top levellocation of mapping fileUnpack pets so they "fill down"But notice how the "optional" elementsin the pets grouping has meant a mismatch indata so "Bugsy" the rabbit, has the breed"Cross-eyed Lion", which actually should attributed to Clarence the Catclear "empty" cellsremove grouping columnsUnpack top levelUnpack address so they "fill down"Unpack pets so they "fill down"Clarence is now the Cross Eyed Lion, because of config change on the Easy Readercomponentclear "empty" cellsremove grouping columnsUnpack pets so they "fill down"Unpack top levelUnpack top levelremove grouping columnsclear "empty" cellsUnpack pets so they "fill down"location of mapping fileNode 64Node 65Notice blanks in the Name and Age columnsName and Age columnsare now populated correctlySome Animals have gone missing! And there's a mismatch of Animal with itsname because of "optional"elements in the XML thatEasy Reader cannot know aboutEasy Reader config made aware of"optional group elements"//pets/petso pets and their names now match upConfig restricts collectionto only the //pets subtreealong with elements outside ofthat subtree as definedunder "key elements"This time we have restricted the collectionof elements byreference in the mapping filerather than by "collection subtree"Read XMLBasic row-based dataRead XMLBasic with additional groupingelement but still tabularRead XMLNested data now has many to onegroupingRead XMLNested data now has many to onegrouping and we use a mapping file nowbecause "name" clashes betweenperson and petRead XMLMapping file continues to be usedto prevent name-clashand we configre the component sothat it knows that items below//pets/petcontain optional entries, so it watches out and pads these accordingly wherethey are missingRead XMLMapping file continues to be usedto prevent name-clashWe are now returning onlyowner nameand petsas defined in the config under "collect from subtree"Read XMLOwners and Addresses (restricted by mapping file entries) Open File or Folder Ungroup Ungroup Open File or Folder Missing ValueColumn Filter Open File or Folder Missing ValueColumn Filter Ungroup Ungroup Missing ValueColumn Filter Ungroup Ungroup Missing ValueColumn Filter Open File or Folder Empty Collectionto Missing Ungroup Open File or Folder Ungroup Open File or Folder Empty Collectionto Missing Missing ValueColumn Filter Ungroup Ungroup Ungroup Empty Collectionto Missing Missing ValueColumn Filter Ungroup Ungroup Ungroup Missing ValueColumn Filter Empty Collectionto Missing Ungroup Open File or Folder Open File or Folder Column AutoType Cast Column AutoType Cast Column AutoType Cast Column AutoType Cast Column AutoType Cast Column AutoType Cast Column AutoType Cast Column AutoType Cast XML Easy Reader 1 XML Easy Reader 1 XML Easy Reader 1 XML Easy Reader 1 XML Easy Reader 1 XML Easy Reader 1 XML Easy Reader 1 Owner with Pets Owner with Address Basic 2-d "table" - simplest format can beloaded without any configuration This example demonstrates a problemthat is resolved by the next example! This example demonstrates a problemthat is resolved by the next example! Node 3Unpack everythingremove grouping columnsremove grouping columnsUnpack everythingStraight unpack DOESN'T"fill down" !!Unpack top levelremove grouping columnsUnpack address so they "fill down"Unpack address so they "fill down"remove grouping columnsclear "empty" cellsUnpack top levellocation of mapping fileUnpack pets so they "fill down"But notice how the "optional" elementsin the pets grouping has meant a mismatch indata so "Bugsy" the rabbit, has the breed"Cross-eyed Lion", which actually should attributed to Clarence the Catclear "empty" cellsremove grouping columnsUnpack top levelUnpack address so they "fill down"Unpack pets so they "fill down"Clarence is now the Cross Eyed Lion, because of config change on the Easy Readercomponentclear "empty" cellsremove grouping columnsUnpack pets so they "fill down"Unpack top levelUnpack top levelremove grouping columnsclear "empty" cellsUnpack pets so they "fill down"location of mapping fileNode 64Node 65Notice blanks in the Name and Age columnsName and Age columnsare now populated correctlySome Animals have gone missing! And there's a mismatch of Animal with itsname because of "optional"elements in the XML thatEasy Reader cannot know aboutEasy Reader config made aware of"optional group elements"//pets/petso pets and their names now match upConfig restricts collectionto only the //pets subtreealong with elements outside ofthat subtree as definedunder "key elements"This time we have restricted the collectionof elements byreference in the mapping filerather than by "collection subtree"Read XMLBasic row-based dataRead XMLBasic with additional groupingelement but still tabularRead XMLNested data now has many to onegroupingRead XMLNested data now has many to onegrouping and we use a mapping file nowbecause "name" clashes betweenperson and petRead XMLMapping file continues to be usedto prevent name-clashand we configre the component sothat it knows that items below//pets/petcontain optional entries, so it watches out and pads these accordingly wherethey are missingRead XMLMapping file continues to be usedto prevent name-clashWe are now returning onlyowner nameand petsas defined in the config under "collect from subtree"Read XMLOwners and Addresses (restricted by mapping file entries)Open File or Folder Ungroup Ungroup Open File or Folder Missing ValueColumn Filter Open File or Folder Missing ValueColumn Filter Ungroup Ungroup Missing ValueColumn Filter Ungroup Ungroup Missing ValueColumn Filter Open File or Folder Empty Collectionto Missing Ungroup Open File or Folder Ungroup Open File or Folder Empty Collectionto Missing Missing ValueColumn Filter Ungroup Ungroup Ungroup Empty Collectionto Missing Missing ValueColumn Filter Ungroup Ungroup Ungroup Missing ValueColumn Filter Empty Collectionto Missing Ungroup Open File or Folder Open File or Folder Column AutoType Cast Column AutoType Cast Column AutoType Cast Column AutoType Cast Column AutoType Cast Column AutoType Cast Column AutoType Cast Column AutoType Cast XML Easy Reader 1 XML Easy Reader 1 XML Easy Reader 1 XML Easy Reader 1 XML Easy Reader 1 XML Easy Reader 1 XML Easy Reader 1

Nodes

Extensions

Links