Last active
November 22, 2017 20:09
-
-
Save quonic/33e1fe707fc7a592a20321bd6fe51e24 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"This:" | |
"<queryxml version='1.0'><entity>Ticket</entity><query><field>TicketNumber<expression op='Equals'>135481</expression></field></query></queryxml>" | |
"should equal this:" | |
$doc = new-object System.Xml.XmlDocument | |
$root = $doc.CreateElement("queryxml") | |
$root.SetAttribute("version","1.0") | |
$entity = $doc.CreateElement("entity") | |
$entity.InnerText = "Ticket" | |
$query = $doc.CreateElement("query") | |
$field = $doc.CreateElement("field") | |
$field.InnerText = "TicketNumber" | |
$expression = $doc.CreateElement("expression") | |
$expression.SetAttribute("op","Equals") | |
$expression.InnerText = "135481" | |
[void]$field.AppendChild($expression) | |
[void]$query.AppendChild($field) | |
[void]$root.AppendChild($entity) | |
[void]$root.AppendChild($query) | |
[void]$doc.AppendChild($root) | |
$doc.OuterXml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a much easier way to logically build an xml file in Powershell. Build from the bottom up.