web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

XMLDocument not load a xml url

(0) ShareShare
ReportReport
Posted on by 1,875

Hi

i have this job and when I execute job  for fist url all is ok but for the second system can read nothing.

static void TEST(Args _args)
{

XmlDocument xmlRates;
XmlNode currencyNode;

str url = "https://www.ecb.europa.eu/.../eurofxref-daily.xml";
str url2 = "https://www.bnr.ro/nbrfxrates.xml";


System.Exception ex;

Set permissionSet;
permissionSet = new Set(Types::Class);
permissionSet.add(new InteropPermission(InteropKind::ClrInterop));
permissionSet.add(new FileIOPermission(url, 'r'));

CodeAccessPermission::assertMultiple(permissionSet);

xmlRates = new XmlDocument();

xmlRates.load(url);

CodeAccessPermission::revertAssert();

permissionSet = new Set(Types::Class);
permissionSet.add(new InteropPermission(InteropKind::ClrInterop));
permissionSet.add(new FileIOPermission(url2, 'r'));

CodeAccessPermission::assertMultiple(permissionSet);

xmlRates = new XmlDocument();

xmlRates.load(url2);

CodeAccessPermission::revertAssert();
}

I have the same question (0)
  • nmaenpaa Profile Picture
    101,166 Moderator on at

    What do you mean by "system can read nothing"? Do you get some error? I don't get any errors.

  • Martin Dráb Profile Picture
    239,122 Most Valuable Professional on at

    Make sure you catch Exception::CLRError and shows the error message, otherwise you won't get any information that an exception was thrown.

    By the way, let me change the category of this thread from Other to Development.

  • XB Profile Picture
    1,875 on at

    I don't get any error basically the object is null anyway this code worked a few weeks ago.

    If I tried to read some node i get a exception object is null

    static void TEST(Args _args)
    {

    XmlDocument xmlRates;
    XmlNode currencyNode;

    str url = "">www.ecb.europa.eu/.../eurofxref-daily.xml";
    str url2 = "">www.bnr.ro/nbrfxrates.xml";

    System.Net.WebClient webClient = new System.Net.WebClient();

    System.Exception ex;

    Set permissionSet;
    permissionSet = new Set(Types::Class);
    permissionSet.add(new InteropPermission(InteropKind::ClrInterop));
    permissionSet.add(new FileIOPermission(url, 'r'));

    CodeAccessPermission::assertMultiple(permissionSet);

    try
    {
    xmlRates = new XmlDocument();

    if(!xmlRates.load(url))
    {
    throw error("Error");
    //return;
    }

    CodeAccessPermission::revertAssert();


    permissionSet = new Set(Types::Class);
    permissionSet.add(new InteropPermission(InteropKind::ClrInterop));
    permissionSet.add(new FileIOPermission(url2, 'r'));

    CodeAccessPermission::assertMultiple(permissionSet);

    xmlRates = new XmlDocument();
    xmlRates.load(url2);
    /*if(!xmlRates.load(url2))
    {
    throw error("Error");
    }*/

    currencyNode = xmlRates.root();
    if (!currencyNode)
    {
    return;
    }

    }
    catch (Exception::CLRError)
    {
    ex = ClrInterop::getLastException();
    if (ex != null)
    {
    info(ex.get_Message());
    ex = ex.get_InnerException();
    if (ex != null)
    error(ex.ToString());
    }
    }
    catch (Exception::Internal)
    {
    ex = ClrInterop::getLastException();
    if (ex != null)
    info(ex.get_Message());
    }

    CodeAccessPermission::revertAssert();


    }

  • nmaenpaa Profile Picture
    101,166 Moderator on at

    I don't get any error. Which line of code throws the error for you?

    Can you access both URLs via browser from your dev system?

  • XB Profile Picture
    1,875 on at

    There is no errors because object is null and I can access via browser.

  • Martin Dráb Profile Picture
    239,122 Most Valuable Professional on at

    It would help if you told us which variable is null and where.

  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    Now I tried your code again and I get an error because the object is indeed null (seems you updated your code after I last tested it). But it comes already with the first URL. In your original message you said that it works ok for the first URL but not for the second?

    Perhaps your code doesn't work at all, which would be a very different problem than having it work ok with one URL and not another.

  • nmaenpaa Profile Picture
    101,166 Moderator on at

    Also, when sharing your code, please click "Use rich text formatting" - "Insert" - "Code" so that it's easier to read.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 689

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 478 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 258 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans