Copied to clipboard

Flag this post as spam?

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


  • Mila 60 posts 79 karma points
    Apr 26, 2012 @ 23:46
    Mila
    0

    How to parse a xml file into umbraco?

    I have a xml file with a list of cities, and I wrote an c# code to get it into a drop down list.

    Here is my code:

     protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    LoadXML();
                }
            }

            public void LoadXML()
            {     
                string cidadeXml = Server.MapPath("~/cidades.xml");
                DataSet dsCidade = new DataSet();

                dsCidade.ReadXml(cidadeXml);
                cidadeDDL.DataSource = dsCidade;
                cidadeDDL.DataTextField = "NOME";
                cidadeDDL.DataValueField = "NOME";
                cidadeDDL.DataBind();
            }

    I want to make it works in my umbraco project. Where can I insert my xml file to be read by a macro.

    I have a macro with this code in my page, but it's returning a erro message:

    Error creating control (usercontrols/Loja Virtual/cadastroControl.ascx).
    Maybe file doesn't exists or the usercontrol has a cache directive, which is not allowed! See the tracestack for more information!
  • Nigel Wilson 945 posts 2077 karma points
    Apr 27, 2012 @ 02:58
    Nigel Wilson
    0

    Hi Mila

    Add "?umbDebugShowTrace=true" to your page to get output on what is causing the error.

    If you can't solve the problem from the resulting output then post the error message and someone may be able to assist.

    Cheers

    Nigel

  • Mila 60 posts 79 karma points
    May 03, 2012 @ 14:44
    Mila
    0

    Thank you very much, Nigel.

    I solved my problem by setting my xml files as directory virtual. It´s working fine now :)

Please Sign in or register to post replies

Write your reply to:

Draft