about_Xml.help.txt

A module providing converters for HTML to XML, various core XML commands and a DSL for generating XML documents.
 
Two ways to convert HTML into XML
=================================
 
Import-Html Load an HTML file to an XML Document
ConvertFrom-Html Load HTML text As an XML Document
 
Commands for working with XML
=============================
 
Set-XmlContent Save an XmlDocument or Node to the specified file path
Get-XmlContent Load an XML file as an XmlDocument
Convert-Xml The Convert-XML function lets you use Xslt to transform XML strings and documents
Format-Xml Pretty-print formatted XML source
Get-XmlContent Load an XML file as an XmlDocument
Set-XmlContent Save an XmlDocument or Node to the specified file path
Remove-XmlElement Removes specified elements (tags or attributes) or all elements from a specified namespace from an Xml document
Remove-XmlNamespace Removes namespace definitions and prefixes from xml documents
Select-Xml The Select-XML cmdlet lets you use XPath queries to search for text in XML strings and documents. Enter an XPath query, and use the Content, Path, or Xml parameter to specify the XML to be searched
Update-Xml The Update-XML cmdlet lets you use XPath queries to replace text in nodes in XML documents. Enter an XPath query, and use the Content, Path, or Xml parameter to specify the XML to be searched
 
Helpers for working with CliXml without files
=============================================
 
ConvertFrom-CliXml Imports CliXml content and creates corresponding objects within Windows PowerShell.
ConvertTo-CliXml Creates an CliXml-based representation of an object or objects and outputs it
 
The XML DSL is quite simple, and very powerful.
===============================================
 
It has only one built-in command "XML" (or New-XDocument), which creates an XML document using simple PowerShell syntax!
 
Any "command" that's not a real command turns into an XML node, and any parameters turn into attributes.
 
Passing a scriptblock to these fake commands creates nested elements.
 
At any point (even nested several levels deep in the XML document) you can call PowerShell commands to output objects and convert them into XML nested inside your document.
 
 
 
 
 
 
 
 
Version History:
 
Select-Xml 2.0 This was the first script version I wrote.
               it didn't function identically to the built-in Select-Xml with regards to parameter parsing
Select-Xml 2.1 Matched the built-in Select-Xml parameter sets, it's now a drop-in replacement
               BUT only if you were using the original with: Select-Xml ... | Select-Object -Expand Node
Select-Xml 2.2 Fixes a bug in the -Content parameterset where -RemoveNamespace was *presumed*
Version 3.0 Added New-XDocument and associated generation functions for my XML DSL
Version 3.1 Fixed a really ugly bug in New-XDocument in 3.0 which I should not have released
Version 4.0 Never content to leave well enough alone, I've completely reworked New-XDocument
Version 4.1 Tweaked namespaces again so they don't cascade down when they shouldn't. Got rid of the unnecessary stack.
Version 4.2 Tightened xml: only cmdlet, function, and external scripts, with "-" in their names are exempted from being converted into xml tags.
               Fixed some alias error messages caused when PSCX is already loaded (we overwrite their aliases for cvxml and fxml)
Version 4.3 Added a Path parameter set to Format-Xml so you can specify xml files for prety printing
Version 4.5 Fixed possible [Array]::Reverse call on a non-array in New-XElement (used by New-XDocument)
               Work around possible variable slipping on null values by:
               1) allowing -param:$value syntax (which doesn't fail when $value is null)
               2) testing for -name syntax on the value and using it as an attribute instead
Version 4.6 Added -Arguments to Convert-Xml so that you can pass arguments to XSLT transforms!
               Note: when using strings for xslt, make sure you single quote them or escape the $ signs.
Version 4.7 Fixed a typo in the namespace parameter of Select-Xml
Version 4.8 Fixed up some uses of Select-Xml -RemoveNamespace
Version 5.0 Added Update-Xml to allow setting xml attributes or node content
Version 6.0 Major cleanup, breaking changes.
      - Added Get-XmlContent and Set-XmlContent for loading/saving XML from files or strings
      - Removed Path and Content parameters from the other functions (it greatly simplifies thost functions, and makes the whole thing more maintainable)
      - Updated Update-Xml to support adding nodes "before" and "after" other nodes, and to support "remove"ing nodes
Version 6.1 Update for PowerShell 3.0
Version 6.2 Minor tweak in exception handling for CliXml
Version 6.3 Added Remove-XmlElement to allow removing nodes or attributes
               This is something I specifically needed to remove "ignorable" namespaces
               Specifically, the ones created by the Visual Studio Workflow designer (and perhaps other visual designers like Blend)
               Which I don't want to check into source control, because it makes diffing nearly impossible
Version 6.4 Fixed a bug on New-XElement for Rudy Shockaert (nice bug report, thanks!)
Version 6.5 Added -Parameters @{} parameter to New-XDocument to allow local variables to be passed into the module scope. *grumble*
Version 6.6 Expose Convert-Xml and fix a couple of bugs (I can't figure how they got here)
Version 6.7 Add ConvertFrom-Html, add -Formatted switch to Set-XmlContent
               Reformat and clean up to (mostly) match the new best practices stuff
               Push to github
               Run the PSScriptAnalyzer