Skip to main content
Hello experts.

 

 

I'm struggling with parsing an XML file into an Access database using xfmap. The XML file is matched on the root level ("Eiendommer", meaning land properties). Each Eiendom contains 1 or more Tax property ("Skatteeiendom"). On each Skatteeiendom there may be 0, 1 or multiple buildings ("Bygg") and this is where the fun begins. To finish the story, in every building there may be 0, 1 or multiple floors ("Etasjer"). I run the XML through 3 consecutive ListExploders in an attempt to retrieve all relevant information from the XML whilst maintaining the relation between floors, buildings and tax properties. This is my first attempt at XML parsing with FME, it may well be that there are better/smarter/more elegant ways to do this.

 

 

My problem with this workspace is that I seem to loose track of the attribute values of elements where there is only 1 building. I run the XML through 3 ListExploders so that lists are formed of buildings, and I can route these attributes to a target table in the Access database, but this works only for lists. Which seems logical - a ListExploder only handles lists, naturally. But how can I get a hold of the attribute values for non-listed elements (1 building on 1 property for example) ?

 

 

Any help would be greatly appreciated and I will buy you a beer next time you are in town. Promise.

 

 

 

Hi,

 

 

It would be helpful if you could share a snippet of the XML.

 

 

Itay
Sorry, of course. Here it comes.

 

 

<?xml version="1.0" encoding="UTF-8"?> <Eiendommer DATO="13.11.2013" KOMMENTAR="" SIGNATUR="liv"> <Skatteeiendom ANR="5480"> <Tomt KNR="1520" GNR="51" SNR="0" YF="1.00" Begrunnelse="" EierTilstede="0" IF="0.60" FNR="0" BNR="12"> <Bygninger> <Bygg Bygningsfaktor="0.60" TYPN="111" STAT="2" NR="179826623" Fritaksbygg="0" Kvalitet="5" Kommentar="Ab før 67" TIBD="01.01.1800" Standard="3" Dato="12.11.2013"> <Etasjer> <Etasje ET="H" BABO="40" BAAB="" PBAR="" ENR="2"> <Protokoller> </Protokoller> </Etasje> <Etasje ET="H" BABO="75" BAAB="0" PBAR="0" ENR="1"> <Protokoller> </Protokoller> </Etasje> </Etasjer> </Bygg> <Bygg Bygningsfaktor="0.40" TYPN="181" STAT="2" NR="179826607" Fritaksbygg="0" Kvalitet="2" Kommentar="Ab før 60" TIBD="01.01.1800" Standard="1" Dato="12.11.2013"> <Etasjer> <Etasje ET="H" BABO="" BAAB="16" PBAR="" ENR="1"> <Protokoller> <Protocol name="G/B i H" areal=""/> </Protokoller> </Etasje> </Etasjer> </Bygg> <Bygg Bygningsfaktor="1.00" TYPN="181" STAT="2" NR="179826615" Fritaksbygg="0" Kvalitet="6" Kommentar="" TIBD="01.01.1800" Standard="3"> <Etasjer> </Etasjer> </Bygg> </Bygninger> </Tomt> </Skatteeiendom>

 

</Eiendommer>  
Hi,

 

 

But how can I get a hold of the attribute values for non-listed elements (1 building on 1 property for example) ?

 

 

By testing if the lists exist, if they do not exist, map to output attributes.

 

If they do > lists exploder(s) and then map to output attributes.

 

 

Basically you have parallel streams 1 for lists and a second one for 'regular' attributes.

 

 

As always there are many ways to do things in FME and probably a more elegant way than this.

 

 

Itay
Hi,

 

 

aaah, this brings back fond memories from using FME to process GAB data ;-)

 

 

Itay is spot on, the list will only exist when there is any info in the record. Example: for a building with no floor definitions, there will be no floor list either.

 

 

That being said, is there a particular reason for using an xfMap file? It might be much easier to use the Feature Path functionality of FME. Have a look here for more info.

 

 

David
Hi,

 

 

Yes using Feature Types to split the xml is a lot easier, there are also some nice tricks on how to get to a specific attribute shown here (see around min 27 for using a path to a specific attribute)

 

 

Itay
🙂
Just realised that I actually had already used FeaturePath. Sorry. Bit confusing with many things going on and at the same time keeping track of all this nerd speak :) 
In the end I used a Listelementcounter with an Attributefilter on the list count attribute to separate lists from non-lists. Mr. Italy, the Norwegian beer (worth 4 FME licenses pr glass) awaits you.

Reply