Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1041429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:21:06+00:00 2026-05-16T15:21:06+00:00

I’m porting a program I wrote on C# to Cocoa and I’m trying to

  • 0

I’m porting a program I wrote on C# to Cocoa and I’m trying to figure out how to use XML to go online to my website, grab the file and parse it, then compare the version and pop a message box to ask if you want to open your browser to the update page.

Here’s the code from C#:

 public void CheckVersion()
    {
        Version newVersion = null;
        string url = "";
        string newfeatures = "";
        try
        {
            string xmlURL = "http://myurl.com/version.xml";
            XmlRead = new XmlTextReader(xmlURL);
            XmlRead.MoveToContent();
            string elementName = "";
            if ((XmlRead.NodeType == XmlNodeType.Element) &&
                (XmlRead.Name == "myProgram"))
            {
                while (XmlRead.Read())
                {
                    if (XmlRead.NodeType == XmlNodeType.Element)
                        elementName = XmlRead.Name;
                    else
                    {
                        if ((XmlRead.NodeType == XmlNodeType.Text) &&
                            (XmlRead.HasValue))
                        {
                            switch (elementName)
                            {
                                case "version":
                                    newVersion = new Version(XmlRead.Value);
                                    break;
                                case "url":
                                    url = XmlRead.Value;
                                    break;
                                case "newfeatures":
                                    newfeatures = XmlRead.Value;
                                    break;
                            }
                        }
                    }
                }
            }
        }
        catch (Exception)
        {
            MessageBox.Show("Could not connect to update checking server.");
        }
        finally
        {
            if (XmlRead != null) XmlRead.Close();
        }
        Version curVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
        if (curVersion.CompareTo(newVersion) < 0)
        {
            string title = "New Version Online";
            string question = "Download new version? \nmyProgram Version: " + newVersion.ToString();
            if (DialogResult.Yes ==
             MessageBox.Show(this, question + "\n\n" + newfeatures, title,
                             MessageBoxButtons.YesNo,
                             MessageBoxIcon.Question))
            {
                System.Diagnostics.Process.Start(url);
            }
        }  
    }

I’m pretty new to cocoa and most of that C# code was a snippet so any advice or help would be great.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T15:21:06+00:00Added an answer on May 16, 2026 at 3:21 pm

    For updates the best solution available is Sparkle, as the others pointed out before.

    But if you still want to know about loading XML from a server and parsing it you should read the documentation for the URL Loading System and on NSXMLDocument. With that it is not hard to get and parse the data, but you won’t be able to stuff everything into one method. NSURLConnection works with delegates so you don’t have to block the current thread while it is getting the data from the server.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.