XMLPort: Import file with header

dreamteamdreamteam Member Posts: 5
edited 2013-10-17 in NAV Three Tier
Hello,

I have a file wich the first line is the Header of the fields. I have to skip the first line but i don´t know how to do this.
I just tried to create a Element Table: <Integer>(Integer) with the SourceTableView: SORTING(Number) WHERE(Number=CONST(1)), like the standard does, but doesn't work. At first i had one error "Integer number '0' alredy exists¡ wich i solved with this code line on the trigger Import::OnBeforeInsertRecord():
Integer.DELETEALL;

But now give's me another error:

"The element <tagname> is expected by min occurs value: Once, Element received <tagname2>"

Somebody knows how to solve this? I'm really frustrated.

Thank you very much.

Comments

  • lvanvugtlvanvugt Member Posts: 774
    Hi dreamteam,

    You're not the first to ask. Search for "XMLport skip header" and find valuable posts, like this one: Import dataport and skipping the header line.
    Luc van Vugt, fluxxus.nl
    Never stop learning
    Van Vugt's dynamiXs
    Dutch Dynamics Community
  • dreamteamdreamteam Member Posts: 5
    Thanks Ivanvugt,
    I've alredy tried this, but is just for old nav version Dataports, not XmlPorts:

    IF CurrDataport.IMPORT THEN BEGIN
    REPEAT
    CurrFile.READ(cha);
    UNTIL cha = 10; // of course in case the RecordSeparator is "<<NewLine>>"
    END;

    I'm using Nav 2013, and CurrDataport, CurrFile and the function READ doesn't exist. I have searched for a long time on mibuso and other sites, but nothing.
    Thanks.
  • dreamteamdreamteam Member Posts: 5
    I'm still stuck :cry:
  • geordiegeordie Member Posts: 655
    The only clue I have is open the file in OnPreXMLport trigger (using currXMLport.FILENAME property), copy it and remove the first line in the copied one; after that overwrite currXMLport.FILENAME with new file and process it.

    Hope it helps.
  • ta5ta5 Member Posts: 1,164
    Hi dreamtteam
    Sometimes you are better off using xmlDOM, meaning you don't use xmlPort but do it all manually. You have to decide if the business case does legitimate this non standard approach, but you get full control of the parsing process, also validitating against schemas and all this stuff.
    Btw: This applies to XML files, not for flat files imported with xmlPort.

    Hope this helps.
    Thomas
  • thegunzothegunzo Member Posts: 274
    Using pure dotnet might solve your issue...

    http://www.dynamics.is/?p=1405
    ________________________________
    Gunnar Gestsson
    Microsoft Certified IT Professional
    Dynamics NAV MVP
    http://www.dynamics.is
    http://Objects4NAV.com
Sign In or Register to comment.