XML 파일의 모든 노드를 수신하는 Linq 문을 작성했습니다.Linq XML - 부모 노드와 자식 노드의 조합으로 고유 값 얻기
foreach (var node in epaXmlLoad.Root.Descendants()
.DescendantNodes()
.OfType<XElement>()
.Distinct())
{
newEntity = true;
xmlModel.Node = node.Name.ToString();
xmlModel.ParentNode = node.Parent.Name.ToString();
model.Save(xmlModel);
}
이렇게하면 노드와 해당 노드의 부모가 테이블에 저장됩니다.
그러나 이것을 실행할 때 테이블에 중복 된 데이터가 있습니다. I 같은 이름이지만 다른 상위 노드가있는 자식 노드가 더 많기 때문에 노드 값에서 구분할 수 없습니다.
<EPC>
<General>
<Input>3</Invoer>
<Amount>3</Amount>
<Name>Bla</Name>
</General>
<Sectors>
<Sector>
<Name>Blalbla</Perc>
<UsageID>0</UsageID>
<Detection>0</Detection>
<Sector>
<Sector>
<Name>Blalbla</Perc>
<UsageID>0</UsageID>
<Detection>0</Detection>
<Sector>
<Sectors>
<Devices>
<Device>
<Name>Bladiebla</name>
<Amount>5</Amount>
<Detection>True</Detection>
</Device>
<Device>
<Name>Bladiebla2</name>
<Amount>5</Amount>
<Detection>True</Detection>
</Device>
<Devices>
는 ^이 XML 내 문제에 대해 설명합니다.
** xml ** 예제와 원하는 결과를 제공 할 수 있습니까? –
질문에 – Koen
을 추가했습니다. 그리고 원하는 출력은 무엇입니까? –