Download String or File with C#

Download a String:
https://docs.microsoft.com/en-us/dotnet/api/system.net.webclient.downloadstring?view=netframework-4.7.2

using System.Net;
...
/// <summary>
/// Download a string with a GET request
/// </summary>
/// <param name="address">URL</param> URL
/// <returns>Requested string</returns>
public static string DownloadString(string address)
{
WebClient client = new WebClient();
string reply = client.DownloadString(address);
return reply;
}

Download a File:
https://docs.microsoft.com/en-us/dotnet/api/system.net.webclient.downloadfile?view=netframework-4.7.2

string remoteUri = "http://www.contoso.com/library/homepage/images/"; string fileName = "ms-banner.gif", myStringWebResource = null; 
// Create a new WebClient instance.
WebClient myWebClient = new WebClient();
// Concatenate the domain with the Web resource filename. myStringWebResource = remoteUri + fileName;
Console.WriteLine("Downloading File \"{0}\" from \"{1}\" .......\n\n", fileName, myStringWebResource);
// Download the Web resource and save it into the current filesystem folder.
myWebClient.DownloadFile(myStringWebResource,fileName); Console.WriteLine("Successfully Downloaded File \"{0}\" from \"{1}\"", fileName, myStringWebResource);
Console.WriteLine("\nDownloaded file saved in the following file system folder:\n\t" + Application.StartupPath);

Using XPath in a C# XmlDocument

Source: https://csharp.net-tutorials.com/xml/using-xpath-with-the-xmldocument-class/

Doing a basic query return a single node (XmlNode):

using System;
using System.Text;
using System.Xml;

namespace ParsingXml
{
    class Program
    {
        static void Main(string[] args)
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load("http://rss.cnn.com/rss/edition_world.rss");
            XmlNode titleNode = xmlDoc.SelectSingleNode("//rss/channel/title");
            if(titleNode != null)
                Console.WriteLine(titleNode.InnerText);
            Console.ReadKey();   
        }
    }
}

Doing query that returns a list of node (XMlNodeList):

using System;
using System.Text;
using System.Xml;

namespace ParsingXml
{
    class Program
    {
        static void Main(string[] args)
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load("http://rss.cnn.com/rss/edition_world.rss");
            XmlNodeList itemNodes = xmlDoc.SelectNodes("//rss/channel/item");
            foreach(XmlNode itemNode in itemNodes)
            {
                XmlNode titleNode = itemNode.SelectSingleNode("title");
                XmlNode dateNode = itemNode.SelectSingleNode("pubDate");
                if((titleNode != null) && (dateNode != null))
                    Console.WriteLine(dateNode.InnerText + ": " + titleNode.InnerText);
            }
            Console.ReadKey();   
        }
    }
}

Make a Dollar Tree Doll into a Poseable Doll

I have an art request and lately I’ve been having trouble getting thr proportions of some of the drawings right. I’ve ordered a couple of poseable dolls on AliExpress but I’ve getting at the end of my of the shipping cycle and they haven’t arrived yet.

So I went searching and found this tutorial to turn a cheap dollar store doll into a poseable doll. I’ll update this post after I make it this afternoon.

MMBasic – Micro Controller Basic Ported to Multiple Platforms

I came across this version of BASIC for a conversation about the C16, a 16-bit of the Commodore 64. From the home page:

MMBasic is a free and open BASIC interpreter for 32 bit microcontrollers.

It includes floating point numbers, extensive string handling, multi dimensional arrays and structured programming features like do loops, multiline if statements, user defined subroutines and functions.

MMBasic is generally backwards compatible with Microsoft's MBASIC and implements much of the ANSI Standard for Full BASIC (X3.113-1987).

If you want to download the compiled version click here.

Geocoding Database – OpenAddresses.io

Site: http://results.openaddresses.io/

The US file are set up as:

  • State Code Folder
    • CountyName.csv

Related Links:

.NET Make an XML Document from Scratch

Source: https://stackoverflow.com/questions/11492705/how-to-create-an-xml-document-using-xmldocument

#region Using Statements
using System;
using System.Xml;
#endregion 

class Program {
    static void Main( string[ ] args ) {
        XmlDocument doc = new XmlDocument( );

        //(1) the xml declaration is recommended, but not mandatory
        XmlDeclaration xmlDeclaration = doc.CreateXmlDeclaration( "1.0", "UTF-8", null );
        XmlElement root = doc.DocumentElement;
        doc.InsertBefore( xmlDeclaration, root );

        //(2) string.Empty makes cleaner code
        XmlElement element1 = doc.CreateElement( string.Empty, "body", string.Empty );
        doc.AppendChild( element1 );

        XmlElement element2 = doc.CreateElement( string.Empty, "level1", string.Empty );
        element1.AppendChild( element2 );

        XmlElement element3 = doc.CreateElement( string.Empty, "level2", string.Empty );
        XmlText text1 = doc.CreateTextNode( "text" );
        element3.AppendChild( text1 );
        element2.AppendChild( element3 );

        XmlElement element4 = doc.CreateElement( string.Empty, "level2", string.Empty );
        XmlText text2 = doc.CreateTextNode( "other text" );
        element4.AppendChild( text2 );
        element2.AppendChild( element4 );

        doc.Save( "D:\\document.xml" );
    }
}