2 ms·
I honestly get annoyed how many platforms say for JSON "yeah, just use the native object querying syntax" while for XML they're all about XPath queries. I have
by Pxtl 6y ago
I honestly get annoyed how many platforms say for JSON "yeah, just use the native object querying syntax" while for XML they're all about XPath queries. I have to google how to XPath every time I use it.
- sidpatil 6y agoPowerShell supports both XPath and native object syntax for reading XML. Unfortunately, by default, writing XML isn't as straightforward. One has to use XmlDocument methods to construct an XML file. The 'Format-XML' cmdlet in the Pscx extension repository [1] does make it possible to use native object syntax to construct XML files, however. [1] https://github.com/Pscx/Pscx https://github.com/Pscx/Pscx
- majkinetor 6y ago> Unfortunately, by default, writing XML isn't as straightforward. Mhm... It can be very simple - you can construct it as a string with @"...@". Add StringBuilder for some speed if there are truly dynamic XMLs with lots of concats. Its way faster then doing regular C# mumbo jumbo and you can test validity easily with [xml]. I generated tones of XML like that and its also very fast. Don't go by the book, rules are there for mediocre :)