Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Asger 25 posts 171 karma points
    Jun 28, 2016 @ 12:50
    Asger
    0

    Get data from XML file

    Hi forum.

    I have the url of a xml file. I now wish to call and use that content on my page.

    What would be the easiest way to do this?

    I have tried with this code that i found in another post, but without luck.

    @using umbraco.MacroEngines
    @inherits DynamicNodeContext
    @try
    {
        dynamic xmlv = new DynamicXml(umbraco.library.GetXmlDocumentByUrl("http://billet.protickets.dk/FilurenNY/servlet/InetSale.GetXMLMovieList"));
    
        <ul>
        @foreach (var property in xmlv)
        {
            <li>
                <p>
                @foreach (var item in property)
                {
                    @item.InnerText<br />
                }
                </p>
            </li>
        }
        </ul>
    }
    catch (Exception e)
    {
        @e.ToString()
    }
    

    I hope someone can help me :)

  • Rhys Hamilton 20 posts 89 karma points
    Jun 28, 2016 @ 13:40
    Rhys Hamilton
    0

    This should retrieve XML data. Note, that it is not formatted. It simply displays text.

    Hopefully this helps. :)

    @using umbraco.MacroEngines
    @try
    {
        dynamic xmlv = new Umbraco.Core.Dynamics.DynamicXml(umbraco.library.GetXmlDocumentByUrl("http://billet.protickets.dk/FilurenNY/servlet/InetSale.GetXMLMovieList"));
    
        <ul>
            @foreach (var property in xmlv)
            {    
                foreach (var item in property)
                {
                  <li>@item.InnerText </li>
                }
            }
        </ul>
    }
    catch (Exception e)
    {
        @e.ToString()
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft