C# LINQ XPath Examples

The following relates to this XML from yesterday’s blog. You can get the surrounding code in that blog. It’s advisable to use the LINQ style of query when possible, but there might be that day where you have a long complicated XPath, and you just want to use with an XElement that you loaded from […]

LINQ XML Navigation Example

Example of how to create XML in memory using LINQ, then how to retrieve elements and attributes from it in the LINQ style. In a future blog, I will show you how to use XPath, and then LINK Query Expressions. This is a sample from Complete Guide to XML for Microsoft Developers (Udemy Course). using […]

Why JavaScript Programmers are so Bonkers for JSON

JavaScript programmers love JSON because it is “baked-in” to the JavaSCript programmnig language. For those of using C#, Python, or Java, we have to use class libraries to assist us with the normal functions that are super-easy in JavaScript. This blog shows you most of you what you need to know about JSON in one […]

Linux/Ubuntu Bash Script to Send All Files in a directory via SFTP

The following script can be scheduled as a “CRON JOB”. It looks at all files (optionally with a file mask) in a given directory, and sends them to a specific SFTP site. This example uses a private key, and the name of that key file is passed as the -i argument on the stp command […]

Generate XSD Schema from XML using PowerShell

I found a C# example of how to create a schema from an XML file here. I wanted to do the same in PowerShell, and this is what I came up with. I left some of the C# code in the script below in comments, just for comparison purposes. The program uses the .NET Schema […]

XPath Axes

This blog shows the shortcuts (i.e. abbreviations) for the most common XPath axes (plural of axis): [table id=2 /] Reference: https://our.umbraco.com/documentation/reference/templating/macros/xslt/xpath-axes-and-their-shortcuts Also see example on the sites below: https://www.way2tutorial.com/xml/xpath-axes.php https://www.w3schools.com/xml/xpath_axes.asp

XPath 3.0 in C# with Saxonica API

Today, I was playing with using Saxonica’s .NET API in C# (Microsoft .NET). The program below was based on the sample here: c:\Saxonica\Resources\samples\cs\ExamplesHE.cs You can download the samples from Saxonica on SourceForge in the file that starts with “Resources”. Sample C# Program <pre> using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; //Do an […]

PowerShell – Create a Directory (Path/Folder) If It Doesn’t Exit

Frequently in PowerShell, we need to add a directory if it doesn’t already exist. Simple Code – Check If the Directory Exists First This assumes the higher level directories exist, and you just want to add the lowest level directory: <pre> $targetFilePath = "e:\Dropbox\Audios\Album\Sinatra" if (!(Test-Path $targetFilePath))   {      New-Item -ItemType Directory -Path $targetFilePath | […]