2012-02-27 3 views
-1

나는 코드 아래 사용 :xml은 Windows phone에서 구문 분석합니까?

같이 XML reader.my XML 파일의 내부 제목 태그를 표시 할 TITLE1의 value.how를 표시 할 때 나는 오류가 발생했습니다
var data = from query in loadedData.Descendants("chapter") 
        select new CountryData 
        { 
         Title = (string)query.Element("title"), 
         data1 = from pharagraph in loadedData.Descendants("pharagraph") 
           select new CountryData 
           { 
            Title1=(string)pharagraph.Element("title"), 
            Des = (string)pharagraph.Element("text"), 
            Position = (int)pharagraph.Element("position"), 
           } 
        }; 
     countryList = data.ToList(); 

: HTTP : //stackoverflow.com/questions/9431276/를

data1 = from pharagraph in loadedData.Descendants("pharagraph") 

을하지만 pharagraphs 요소 (또는 XML에 따라 그 같은)에서 : 아마 loadedData에서하지 pharagraph을 선택

답변

1

을 윈도우 폰-을 위해 - - 동적 XML 판독기를 읽을

data1 = from pharagraph in (query.Element("pharagraphs")).Descendants("pharagraph") 

전체 코드 :

var data = from query in loadedData.Descendants("chapter") 
       select new CountryData 
       { 
        Title = (string)query.Element("title"), 
        data1 = (from pharagraph in (query.Element("pharagraphs")).Descendants("pharagraph") 
          select new CountryData 
          { 
           Title1=(string)pharagraph.Element("title"), 
           Des = (string)pharagraph.Element("text"), 
           Position = (int)pharagraph.Element("position"), 
          }).ToList() 
       }; 
    countryList = data.ToList(); 
+0

하지만 위와 같이 XML 데이터를 구문 분석하는 몇 가지 예제 코드를 제공 explain.please 위 code.please를 사용할 때 오류가 있었다. – Malarkodi

+0

내 대답이 업데이트되었습니다. 'string'으로 캐스트하는 것은 원치 않았습니다. 또한 ToList()를 추가했습니다. 희망이 도움이 – Ku6opr

+0

대단히 감사합니다. 내가 텍스트 블록에 Title1 값을 바인딩 할 때 나는 error.sorry 윈도우 phone.i에 새로운 오전 내 자리에 가이드가 없었어요. – Malarkodi