Exploring XML Document by Using the [XML] Type Accelerator

Doctor Scripto

Summary: Learn how to use theĀ [XML] type accelerator to explore XML documents.

Microsoft Scripting Guy, Ed Wilson, is here. The Scripting Wife bought me a pound of English Breakfast tea that she found online somewhere. It is long leaf, robust, and has a hint of earth tones in the bouquet. It makes a wonderfully rich pot of tea. It was a complete surprise when the box showed up on the door step. I added a cinnamon stick, like I normally do, but I thought I would try this tea basically unaltered to get a sense of what it has to offer. In a way, the tea is similar to todayā€™s excursion into XML.

NoteĀ  This is the second in a series of posts about XML. Yesterday, I talked about using XML Notepad in Creating an XML Document for Admins. You might want to explore that post before continuing with todayā€™s.

There are several tools that can be used to explore an XML document. I can simply double-click the XML document and view it in Internet Explorer (assuming that is the default file association with XML). The following image provides an example of the output:

Image of command output

To be honest, Internet Explorer (or any browser for that matter) is not a very good XML viewer. I would rather view it in Notepad than Internet Explorer. On my system, the default application for XML files is not Internet Explorer, but rather XML Notepad, which in addition to being lightweight, actually has facilities for dealing with XML. So the Users.xml file looks like this in XML Notepad:

Image of menu

The way I prefer to look at XML documents, however, is via Windows PowerShell.

Use PowerShell to peruse XML docs

Using Windows PowerShell to open an XML document is so easy that people have a tendency to lock up. At its most basic, an XML document is a text file. What do I use to open a text file in Windows PowerShell? I use the Get-Content cmdlet. And that is the same cmdlet I use for XML. The only difference is that I use the [XML] type accelerator to convert the plain text into an XML document. This is really easy. Because when I use Get-Content to read a text file, most of the time I store the resulting text in a variable. This is the same thing I do with XML. The technique is shown here:

[XML]$users = Get-Content C:\fso\users.xml

I now have an XMLDocument object. The object members are shown here:

PS C:\> $users | Get-Member

Ā 

Ā Ā  TypeName: System.Xml.XmlDocument

Ā 

NameĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MemberTypeĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  Definition

—-Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  ———-Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  ———-

ToStringĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  CodeMethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  static string XmlNode(psobject insta…

AppendChildĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  Ā Ā Ā MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Xml.XmlNode AppendChild(Syste…

CloneĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Xml.XmlNode Clone(), System.O…

CloneNodeĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Xml.XmlNode CloneNode(bool deep)

CreateAttributeĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Xml.XmlAttribute CreateAttrib…

CreateCDataSectionĀ Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Xml.XmlCDataSection CreateCDa…

CreateCommentĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Xml.XmlComment CreateComment(…

CreateDocumentFragmentĀ Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Xml.XmlDocumentFragment Creat…

CreateDocumentTypeĀ Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Xml.XmlDocumentType CreateDoc…

CreateElementĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Xml.XmlElement CreateElement(…

CreateEntityReferenceĀ Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Xml.XmlEntityReference Create…

CreateNavigatorĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Xml.XPath.XPathNavigator Crea…

CreateNodeĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Xml.XmlNode CreateNode(System…

CreateProcessingInstruction MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Xml.XmlProcessingInstruction …

CreateSignificantWhitespace MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Xml.XmlSignificantWhitespace …

CreateTextNodeĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā  Ā Ā Ā Ā Ā Ā System.Xml.XmlText CreateTextNode(st…

CreateWhitespaceĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Xml.XmlWhitespace CreateWhite…

CreateXmlDeclarationĀ Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Xml.XmlDeclaration CreateXmlD…

EqualsĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  bool Equals(System.Object obj)

GetElementByIdĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Xml.XmlElement GetElementById…

GetElementsByTagNameĀ Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Xml.XmlNodeList GetElementsBy…

GetEnumeratorĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  Ā Ā Ā MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Collections.IEnumerator GetEn…

GetHashCodeĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  int GetHashCode()

GetNamespaceOfPrefixĀ Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  string GetNamespaceOfPrefix(string p…

GetPrefixOfNamespaceĀ Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  string GetPrefixOfNamespace(string n…

GetTypeĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  type GetType()

ImportNodeĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Xml.XmlNode ImportNode(System…

InsertAfterĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā  Ā Ā Ā Ā Ā Ā System.Xml.XmlNode InsertAfter(Syste…

InsertBeforeĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Xml.XmlNode InsertBefore(Syst…

LoadĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  void Load(string filename), void Loa…

LoadXmlĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  void LoadXml(string xml)

NormalizeĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  void Normalize()

PrependChildĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Xml.XmlNode PrependChild(Syst…

ReadNodeĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Xml.XmlNode ReadNode(System.X…

RemoveAllĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  void RemoveAll()

RemoveChildĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Xml.XmlNode RemoveChild(Syste…

ReplaceChildĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Xml.XmlNode ReplaceChild(Syst…

SaveĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  void Save(string filename), void Sav…

SelectNodesĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Xml.XmlNodeList SelectNodes(s…

SelectSingleNodeĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Xml.XmlNode SelectSingleNode(…

SupportsĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  bool Supports(string feature, string…

ValidateĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  void Validate(System.Xml.Schema.Vali…

WriteContentToĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  void WriteContentTo(System.Xml.XmlWr…

WriteToĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  void WriteTo(System.Xml.XmlWriter w)

ItemĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  ParameterizedProperty System.Xml.XmlElement Item(string na…

UsersĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  PropertyĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Xml.XmlElement Users {get;}

xmlĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  PropertyĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  string xml {get;set;}

I can see from the previous output that there are a lot of methods for dealing with XMLDocument objects via the .NET Framework. I can look up the System.XML.XMLDocument object on MSDN and find additional information about each of these methods. Today, I am interested in the properties. There are two properties: Users and XML. There is also a parameterized property called Item. Other than that, everything is a method of some sort.

To look at the values of the two properties, all I need to do is to look at the variable. I type the $users variable in the Windows PowerShell console and press ENTER. The output is less than impressive. It is shown here:

PS C:\> $users

Ā 

xmlĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Users

—Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  —–

version=”1.0″ encoding=”utf-8″Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  Users

I decide to look at what is in the XML property first:

PS C:\> $users.xml

version=”1.0″ encoding=”utf-8″

Is there anything else? When I pipe it to Get-Member, I see that I have a System.String:

PS C:\> $users.xml | gm

Ā 

Ā Ā  TypeName: System.String

Ā 

NameĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MemberTypeĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  Definition

—-Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  ———-Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  ———-

CloneĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.Object Clone(), System.Object

CompareToĀ Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  int CompareTo(System.Object value),

ContainsĀ Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  bool Contains(string value)

CopyToĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  Ā void CopyTo(int sourceIndex, char[]

EndsWithĀ Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  bool EndsWith(string value), bool En

EqualsĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  bool Equals(System.Object obj), bool

GetEnumeratorĀ Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  System.CharEnumerator GetEnumerator(

GetHashCodeĀ Ā Ā Ā Ā  MethodĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  int GetHashCode()

When I look at the Users property, I receive a series of user objects:

PS C:\> $users.Users

Ā 

User

—-

{User, User, User, User…}

So, I continue to drill down.

The User node:

PS C:\> $users.Users.User

Ā 

IDĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  UserNameĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  Address

—Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  ——–Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  ——-

0Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  UserNameĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  Address

0Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  UserNameĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  Address

0Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  UserNameĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  Address

0Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  UserNameĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  Address

0Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  Ā Ā Ā Ā Ā Ā Ā Ā UserNameĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  Address

The UserName node:

PS C:\> $users.Users.User.username

Ā 

FirstNameĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  LastNameĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  #textĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  Password

———Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  ——–Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  —–Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  ——–

BobĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  SmithĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  BobSmithĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  password

BobĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  SmithĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  BobSmithĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  password

BobĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  SmithĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  BobSmithĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  password

BobĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  SmithĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  BobSmithĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  password

BobĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  SmithĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  BobSmithĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  password

And finally, the #Text property that contains the actual user name:

PS C:\> $users.Users.User.username.”#text”

BobSmith

BobSmith

BobSmith

BobSmith

BobSmith

PS C:\>

Dude, all these look like the same thing. Is this right?

As a matter of a fact, it isā€”because all I did yesterday was duplicate each of the user objects. I did not go to the trouble of modifying any of the values. I can easily prove this by opening the XML document in XML Notepad and expanding a few of the nodes. This is shown here:

Image of menu

That is all there is to parsing XML. XML Week will continue tomorrow when I will talk about more cool stuff.

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.

Ed Wilson, Microsoft Scripting GuyĀ 

0 comments

Discussion is closed.

Feedback usabilla icon