how i can check if this header exists?
I am trying to check in my xml file if HeaderReportUnit exists, how i can check if this Header exists ? I am using 2.0 assembly , really thanks for help
<?xml version="1.0" encoding="UTF-8" ?>
- <HeadReportUnit>
- <Title>
<ModuleNum>ModuleNum</ModuleNum>
<hdstSetPos>hdstSetPos</hdstSetPos>
<hdstNzlName>hdstNzlName</hdstNzlName>
<nzavSpecName>nzavSpecName</nzavSpecName>
<nzavNzlDiameter>nzavNzlDiameter</nzavNzlDiameter>
<nzavNzlSizeX>nzavNzlSizeX</nzavNzlSizeX>
<nzavNzlSizeY>nzavNzlSizeY</nzavNzlSizeY>
<nzavNzlType2>nzavNzlType2</nzavNzlType2>
</Title>
- <Unit>
<ModuleNum>1</ModuleNum>
<hdstSetPos>1- 1</hdstSetPos>
<hdstNzlName>R07-007-070</hdstNzlName>
<nzavSpecName>AA05700</nzavSpecName>
<nzavNzlDiameter>0.0</nzavNzlDiameter>
<nzavNzlSizeX>0.7</nzavNzlSizeX>
<nzavNzlSizeY>0.6</nzavNzlSizeY>
<nzavNzlType2>Standard</nzavNzlType2>
</Unit>
- <Unit>
<ModuleNum>1</ModuleNum>
<hdstSetPos>1- 2</hdstSetPos>
<hdstNzlName>R07-007-070</hdstNzlName>
<nzavSpecName>AA05700</nzavSpecName>
<nzavNzlDiameter>0.0</nzavNzlDiameter>
<nzavNzlSizeX>0.7</nzavNzlSizeX>
<nzavNzlSizeY>0.6</nzavNzlSizeY>
<nzavNzlType2>Standard</nzavNzlType2>
</Unit>
- <Unit>
<ModuleNum>1</ModuleNum>
<hdstSetPos>1- 3</hdstSetPos>
<hdstNzlName>R07-007-070</hdstNzlName>
<nzavSpecName>AA05700</nzavSpecName>
<nzavNzlDiameter>0.0</nzavNzlDiameter>
<nzavNzlSizeX>0.7</nzavNzlSizeX>
<nzavNzlSizeY>0.6</nzavNzlSizeY>
<nzavNzlType2>Standard</nzavNzlTy开发者_如何学Pythonpe2>
</Unit>
- <Unit>
<ModuleNum>1</ModuleNum>
<hdstSetPos>1- 4</hdstSetPos>
<hdstNzlName>R07-007-070</hdstNzlName>
<nzavSpecName>AA05700</nzavSpecName>
<nzavNzlDiameter>0.0</nzavNzlDiameter>
<nzavNzlSizeX>0.7</nzavNzlSizeX>
<nzavNzlSizeY>0.6</nzavNzlSizeY>
<nzavNzlType2>Standard</nzavNzlType2>
</Unit>
- <Unit>
<ModuleNum>1</ModuleNum>
<hdstSetPos>1- 5</hdstSetPos>
<hdstNzlName>R07-007-070</hdstNzlName>
<nzavSpecName>AA05700</nzavSpecName>
<nzavNzlDiameter>0.0</nzavNzlDiameter>
<nzavNzlSizeX>0.7</nzavNzlSizeX>
<nzavNzlSizeY>0.6</nzavNzlSizeY>
<nzavNzlType2>Standard</nzavNzlType2>
</Unit>
- <Unit>
<ModuleNum>1</ModuleNum>
<hdstSetPos>1- 6</hdstSetPos>
<hdstNzlName>R07-007-070</hdstNzlName>
<nzavSpecName>AA05700</nzavSpecName>
<nzavNzlDiameter>0.0</nzavNzlDiameter>
<nzavNzlSizeX>0.7</nzavNzlSizeX>
<nzavNzlSizeY>0.6</nzavNzlSizeY>
<nzavNzlType2>Standard</nzavNzlType2>
</Unit>
- <Unit>
<ModuleNum>1</ModuleNum>
<hdstSetPos>1- 7</hdstSetPos>
<hdstNzlName>R07-007-070</hdstNzlName>
<nzavSpecName>AA05700</nzavSpecName>
<nzavNzlDiameter>0.0</nzavNzlDiameter>
<nzavNzlSizeX>0.7</nzavNzlSizeX>
<nzavNzlSizeY>0.6</nzavNzlSizeY>
<nzavNzlType2>Standard</nzavNzlType2>
</Unit>
- <Unit>
<ModuleNum>1</ModuleNum>
<hdstSetPos>1- 8</hdstSetPos>
<hdstNzlName>R07-007-070</hdstNzlName>
<nzavSpecName>AA05700</nzavSpecName>
<nzavNzlDiameter>0.0</nzavNzlDiameter>
<nzavNzlSizeX>0.7</nzavNzlSizeX>
<nzavNzlSizeY>0.6</nzavNzlSizeY>
<nzavNzlType2>Standard</nzavNzlType2>
</Unit>
- <Unit>
<ModuleNum>1</ModuleNum>
<hdstSetPos>1- 9</hdstSetPos>
<hdstNzlName>R07-007-070</hdstNzlName>
<nzavSpecName>AA05700</nzavSpecName>
<nzavNzlDiameter>0.0</nzavNzlDiameter>
<nzavNzlSizeX>0.7</nzavNzlSizeX>
<nzavNzlSizeY>0.6</nzavNzlSizeY>
<nzavNzlType2>Standard</nzavNzlType2>
</Unit>
- <Unit>
<ModuleNum>1</ModuleNum>
<hdstSetPos>1- 10</hdstSetPos>
<hdstNzlName>R07-007-070</hdstNzlName>
<nzavSpecName>AA05700</nzavSpecName>
<nzavNzlDiameter>0.0</nzavNzlDiameter>
<nzavNzlSizeX>0.7</
nzavNzlSizeX
You could select the node with an XPathNavigator and see if there is a result.
For example:
FileStream stream = new FileStream("c:\\file.xml", FileMode.Open);
XPathDocument document = new XPathDocument(stream);
XPathNavigator navigator = document.CreateNavigator();
XPathNodeIterator node = navigator.Select("/HeadReportUnit");
if (node.Count > 0)
{
// do stuff
}
精彩评论