How to Search and Navigate XML Nodes
Posted
by edison681
on Stack Overflow
See other posts from Stack Overflow
or by edison681
Published on 2010-05-24T22:48:47Z
Indexed on
2010/05/24
23:21 UTC
Read the original article
Hit count: 215
I have the following XML :
<LOCALCELL_V18 ID = "0x2d100000">
<MXPWR ID = "0x3d1003a0">100</MXPWR>
</LOCALCELL_V18>
<LOCALCELL_V18 ID = "0x2d140000">
<MXPWR ID = "0x3d1403a0">200</MXPWR>
</LOCALCELL_V18>
<LOCALCELL_V18 ID = "0x2d180000">
<MXPWR ID = "0x3d1803a0">300</MXPWR>
</LOCALCELL_V18>
I want to get the inner text of each <MXPWR>
. however, it is not allowed to use ID# to locate the inner text since it is not always the same. here is my code:
XmlNodeList LocalCell = xmlDocument.GetElementsByTagName("LOCALCELL_V18");
foreach (XmlNode LocalCell_Children in LocalCell)
{
XmlElement MXPWR = (XmlElement)LocalCell_Children;
XmlNodeList MXPWR_List = MXPWR.GetElementsByTagName("MXPWR");
for (int i = 0; i < MXPWR_List.Count; i++)
{
MaxPwr_form_str = MXPWR_List[i].InnerText;
}
}
Any opinion will be appreciated.
© Stack Overflow or respective owner