웹 서비스 호출에서받은 문자열로받은 XMl 문서를 구문 분석하려고합니다. XmlReader는 이스케이프 처리되지 않은 & s로 문서 읽기
String content = ...;//long xml document
using(TextReader reader = new StringReader(content))
using(XmlReader xml_reader = XmlReader.Create(reader, settings))
{
XML = new XPathDocument(xml_reader);
}
그러나 나는 예외가 얻을 : 그러나 20 ~ 30 문자 이전의 나는 것으로 나타났습니다,
An error occurred while parsing EntityName. Line 1, position 1721.
내가 그 문자 주변의 문서를보고하고 임의의 태그의 한가운데에 있었다가 이스케이프 처리되지 않은 앰퍼샌드 (& 자)이므로 문제가 있다고 생각합니다.
실행 :
content.Substring(1700, 100);//results in the following text
"alue>1 time per day& with^honey~&water\\\\</Value></Frequency></Direction> </Directions> "
^unescaped & char 1721 is the 'w'
어떻게 성공적으로 XML로이 문서를 읽을 수 있습니까?
이 XMI 공급자에게 버그로 신고하십시오. 이 코드를 생성하는 코드는 잘못되었으므로 수정해야합니다. –