0
votes

I trying to parse this xml string :

<form name="generatedForm" role="form">  <div class="form-group">    <label for="result">      Calculation Result    </label>    <input class="form-control" name="result" cam-variable-type="Long" cam-variable-name="result" type="text" />    <div ng-if="this.generatedForm.result.$invalid && this.generatedForm.result.$dirty" class="has-error">      <div ng-show="this.generatedForm.result.$error.required" class="help-block">        Required field      </div>      <div ng-show="this.generatedForm.result.$error.camVariableType" class="help-block">        Only a long value is allowed      </div>    </div>  </div>  <div class="form-group">    <label for="correcto">      es correcto?    </label>    <input class="form-control" name="correcto" cam-business-key type="checkbox" />    <div ng-if="this.generatedForm.correcto.$invalid && this.generatedForm.correcto.$dirty" class="has-error">      <div ng-show="this.generatedForm.correcto.$error.required" class="help-block">        Required field      </div>      <div ng-show="this.generatedForm.correcto.$error.camVariableType" class="help-block">        Only a boolean value is allowed      </div>    </div>  </div></form>

The code what I'm using is :

var x =XDocument.Parse("XmlString");

But i recieving System.Xml.XmlException: 'An error occurred while parsing EntityName. Line 1, position 290.'

I tried changig the encoding but the result is the same.

Thanks in advance.

Your XML is malformed. Upload it to xmlvalidation.com and you will get an error 1: 290 The entity name must immediately follow the '&' in the entity reference.. The problem is with this attribute value: <div ng-if="this.generatedForm.result.$invalid &&... The & character must be escaped as per the XML Standard. You need to fix the XML, XDocument and XmlReader are designed only to parse well-formed XML. - dbc
You need to escape & as &amp; and also you cannot have attributes with no value. Is this HTML as opposed to XML? If so parse with HTMLAgilityPack - Charlieface
Yeah is an html and I trying to convert to xml to use linq to perform some searches after. - Ivan Fontalvo