XML in 3.10

andyjarvisandyjarvis Member Posts: 9
edited 2005-02-09 in Navision Attain
How do i get XML output from several tables in V 3.10 Navision??
I take it i use a dataport but the only way i can see to do it is to create the tags manually??
Do any of you guys and Gals have some sample code for doing this, Im afraid ive been spoilt by V4 XML Ports!!

Thanks in advance
Andy

Comments

  • alanperualanperu Member Posts: 23
    Hello Again!

    I'm not sure about the Object numbering for different suppliers of the Payroll module, but you should have a Report for the End of Year Payroll submission - my object id is Report 9000238. This uses functions to output start and end tags and the values. The XML generated is then used by the Internet Submission codeunit.

    Have a look at that report if you have access to it. If not, let me know and I will see what i can do for you.

    I'm afraid its all manual tags though - sorry!
  • andyjarvisandyjarvis Member Posts: 9
    Im afraid i dont have that - or the payroll modules at all, we are offshore so dont have standard UK Payroll, we have developed our own, Can you help any further! I am starting to get desperate!! :shock:
  • jhoekjhoek Member Posts: 216
    Why don't you just use the Microsoft XML Core Services library? The latest version can be downloaded from http://msdn.microsoft.com/xml/default.aspx, but I think all recent Windows version also come with the latest version.
    Kind regards,

    Jan Hoek
    Product Developer
    Mprise Products B.V.
  • randrewsrandrews Member Posts: 135
    I haven't license to see codeunit. But I use the codeunit "XML-Excel Reports Mgt." by analogy with another reports.
    This codeunit create XML file in temporary folder before running excel.
  • alanperualanperu Member Posts: 23
    The last time I needed to get data out of Navision and into an XML file I created a c# app that used c/odbc to get the values from Navision. This allowed me to easily use an xml schema and xml validation in my c# app.

    Would you be able to try this instead?

    I will provide some sample Navision code for simple output to a file if you don't want to use the .net route - I am just trying to make sure this is your only option.

    Thoughts?
  • andyjarvisandyjarvis Member Posts: 9
    Some sample C# code may be the way forward but i wrote a VB6 app to do the job and it failed due to the C/ODBC Driver being slow connecting and it would have taken over 1 2hours to run due to the amount of data!!
    I can give it a go though.,
  • alanperualanperu Member Posts: 23
    Ok, lets try direct from Navision!

    Add a variable fo type 'File', say myFile. Now create 2 functions; one called 'AddTag' and another called 'AddTagAndValue'.

    AddTag should take in 2 text parameters (myTag and myAttribute) and AddTagAndValue should take in 2 text parameters (myTag and myValue).

    AddTag should do something like this:

    IF myAttribute <> '' THEN
    outputText := '<' + myTag + ' ' + myAttribute + '>';
    ELSE
    outputText := '<' + myTag + '>';
    myFile.WRITE(outputText);


    AddTagAndValue should do this:

    outputText := '<' + myTag + '>' + myValue + '<\' + myTag + '>';
    myFile.WRITE(outputText);


    In your Codeunit/Dataport/Report/Form you can then do something like:

    AddTag('EmployeeList','');
    AddTag('Employee','id=1');
    AddTagAndValue('Name','Jeff Jefferson');
    AddTagAndValue('Age','32');
    AddTag('/Employee','');
    AddTag('Employee','id=2');
    AddTagAndValue('Name','John Johnson');
    AddTagAndValue('Age','43');
    AddTag('/Employee','');
    AddTag('/EmployeeList','');

    This should produce XML that looks a bit like this:

    <EmployeeList>
    <Employee id=1>
    <Name>Jeff Jefferson</Name>
    <Age>32</Age>
    </Employee>
    <Employee id=2>
    <Name>John Johnson</Name>
    <Age>43</Age>
    </Employee>
    </EmployeeList>

    Will this do what you are looking for?

    You just need to set up your filename and path and you should be good to go! Obviously, I imagine you will need to set up some loop structures to get the correct XML, but this should be a start.

    This code has not been checked, so you may need to tweak it a little!

    Let me know how you get on!
  • andyjarvisandyjarvis Member Posts: 9
    Thankyou a massive amount, that works a treat, just put that code in a report basically so it loop[ed through employees ok and then added in fielname on an option screen,
    Fab

    Thanks a lot.
Sign In or Register to comment.