Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Team, please help me how can I validate following xml format using PowerShell. See the forth line don't have "<".

<AccountValue>
	<IsNumeric>false</IsNumeric>
	<Length>1,2,3,4,5</Length>
	StartChars/>
	<TrailChars/>
	<Expression>^[0-9]+$</Expression>
</AccountValue>


suppose I save the above content in c:\temp\test.xml. And when I run following code it did not show any error.

$xmlfile = c:\temp\test.xml
$xml = New-Object System.Xml.XmlDocument
$xml.Load($xmlfile)


My question is how can I produce the error without xsd.
xml.Load($xmlfile)
should produce error.

What I have tried:

I tried XmlDocument.Load Method but it did not show any error.
Posted
Updated 7-May-20 17:33pm
v4
Comments
F-ES Sitecore 7-May-20 12:02pm    
What do you mean by "validate"? The XML is invalid, the error you get when calling Load tells you that, so there is your answer.
mkumar2511 7-May-20 23:09pm    
No it is not showing any error when call Load method. And that is the issue.

1 solution

Quite a few suggestions: powershell validate xml - Google Search[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900