XPath 쿼리를 사용하여 xml 문서의 루트 노드에있는 모든 자식 노드를 선택하려고합니다.루트 노드에 속성이있을 때 xml 루트 노드를 선택하는 방법은 무엇입니까?
<?xml version="1.0" encoding="UTF-8" ?>
<root>
<automotive_industry>
<automotive />
<rail_global_services />
</automotive_industry>
</root>
및
<?xml version="1.0" encoding="UTF-8" ?>
<root xmlns="http://www.my_department.my_company.com/project_name">
<automotive_industry>
<automotive />
<rail_global_services />
</automotive_industry>
</root>
C# 코드를 다음과 같이 루트 노드가 선택 :이 코드는 잘 작동
XmlDocument gazetteDocument = new XmlDocument();
gazetteDocument.Load(xmlFilePath);
XmlNodeList allNodes = gazetteDocument.SelectNodes("root");
를, 그것은
내 xml 파일은 다음과 같은 형태 루트 노드가 어떤 속성도 가지지 않을 때 루트 노드의 모든 자식 노드를 선택합니다. 즉, 첫 xml fi에서 작동합니다 le 파일은 xmlns 속성을 가지고 있기 때문에 제 2 xml 파일에서는 작동하지 않습니다.
루트 노드에 특성이있을 때 루트 노드의 모든 자식 노드를 선택하는 방법을 아는 사람이 있습니까 ??
편집 : 내가 한 XPath 쿼리를 발견 /*
이 쿼리는 상관없이 어떤 속성이 있는지 여부 루트 노드를 선택합니다. 루트 노드가 선택되면 모든 하위 노드를 반복 할 수 있습니다.
[C#에서 기본 네임 스페이스로 Xpath 사용] (http://stackoverflow.com/questions/585812/using-xpath-with-default-namespace-in-c) –