2010-03-18 9 views
-1

XML 파서가 질식하는 XML 파일이 있습니다. 그것의 일부입니다 : 내가 가진XML에서 합법적으로 CDATA 사용

<closedDeal><customer><![CDATA[ABC ]]></customer></closedDeal> 

오류가

The literal string ']]>' is not allowed in element content. Error processing resource 

CDATA를 사용하는 올바른 방법은 무엇입니까

입니까? 데이터를 Excel에서 읽었으므로 ALT + ENTER 공백과 같은 잘못된 문자가 포함될 수 있으므로 CDATA가 필요합니다.

도와주세요. 감사합니다. .

+0

당신이 오류를 발생시키는 코드를 게시 할 수 없습니다 : 다음 코드를 사용

<?xml version="1.0" encoding="utf-8" ?> <closedDeal> <customer><![CDATA[ABC ]]></customer> </closedDeal> 

: .NET에서 예를 들어 나는 성공적으로 XML을 구문 분석? –

+0

예, 여기에 게시하지 않은 다른 곳에서 오류가 발생했습니다 :) – idazuwaika

답변

2

어떤 파서를 사용하고 있습니까? 보여준 샘플은 분명히 유효한 XML입니다.

using System; 
using System.Xml.Linq; 
using System.Xml.XPath; 

public class Program 
{ 
    static void Main(string[] args) 
    { 
     var doc = XElement.Load("test.xml"); 
     doc.XPathSelectElement("//customer"); 
     Console.WriteLine(doc.Value); 
    } 
} 
+0

err .. ok thanks. 오류는 여기에 넣지 않은 더 긴 코드에서 발생했습니다. 폐점했다]]> 개점 없음 idazuwaika