이상한 문제가있어서 XDocument와 관련된 모든 것을 시도했습니다.XDocument 여러 네임 스페이스
"CategoryClass"노드의 값을 가져 와서 "ListBoxClass"유형의 자체 개체에 하위 노드를 채우고 싶습니다. 그러나 LINQ 쿼리는 아무것도 반환하지 않습니다. 여기
System.Xml.Linq.XNamespace lName = xDoc.Root.GetDefaultNamespace();
System.Xml.Linq.XNamespace lANamespace = "http://schemas.datacontract.org/2004/07/KRefreshService";
var lEle = from xml2 in xDoc.Element(lName + "GetCategoriesResponse").Element(lName + "GetCategoriesResult").Elements(lANamespace + "CategoryClass")
select new ListBoxClass
{
Id = (int)xml2.Element(lName + "ID"),
Name = xml2.Element(lName+ "CatName").ToString(),
Description = xml2.Element(lName + "CatDescription").ToString()
};
이 문제는이 쿼리의 일부인 XML
<GetCategoriesResponse xmlns="http://tempuri.org/">
<GetCategoriesResult xmlns:a="http://schemas.datacontract.org/2004/07/KRefreshService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:CategoryClass>
<a:CatDescription>General questions regarding IQ. These questions will help you prepare for the interviews.</a:CatDescription>
<a:CatName>IQ</a:CatName>
<a:ID>1</a:ID>
</a:CategoryClass>
<a:CategoryClass>
<a:CatDescription>This category will help you improve your general knowledge. It have information from all the different subjects.</a:CatDescription>
<a:CatName>General Knowledge</a:CatName>
<a:ID>2</a:ID>
</a:CategoryClass>
<a:CategoryClass>
<a:CatDescription>If you feel that you computer science basics are slipping by your head as you involve more in technology. No problem! subscribe to this category.</a:CatDescription>
<a:CatName>Computer Science</a:CatName>
<a:ID>3</a:ID>
</a:CategoryClass>
문제가 무엇인지 말씀하지 않으 셨습니다. 몇 가지 코드와 XML 문서의 일부분을 제공했지만 실제로 질문하지는 않습니다. –
죄송합니다, 문제가 추가되었습니다. –