Hi Abel,
Thanks for posting in the community!
From your description, you are looking for some suggestions on using the
XmlNodeList class in System.Xml namespace to perform the same as the
IXMLDOMSelection component in MSXML COM component, yes?
If there is anything I misunderstood, please feel free to let me know.
Based on my research, you may use the XmlNodeList together with the
XmlDocument class's SelectNodes method( in fact ,this method also avaliable
on the XmlNode class) which can return a XmlNode Array via the XPath you
provided as param. For example, here is a generic code snippet:
----------------------------------------------------------------
private void button6_Click_1(object sender, System.EventArgs e)
{
try
{
String xmlString = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Events>" +
"<event><MySession date=\"date_0_0\" time=\"time_0_0\"
location=\"location_0_0\" /><MySession date=\"date_0_1\" time=\"time_0_1\"
location=\"location_0_1\" /></event>" +
"<event><MySession date=\"date_1_0\" time=\"time_1_0\"
location=\"location_1_0\" /></event>" +
"<event><MySession date=\"date_2_0\" time=\"time_2_0\"
location=\"location_2_0\" /><MySession date=\"date_2_1\" time=\"time_2_1\"
location=\"location_2_1\" /></event></Events>";
XmlDocument doc = new XmlDocument();
doc.LoadXml(xmlString);
XmlNodeList events = doc.SelectNodes("//Events/event");
for(int i=0;i<events.Count;i++)
{
XmlNode evt = events[i];
XmlNodeList sessions = evt.SelectNodes("MySession");
for(int j=0;j<sessions.Count;j++)
{
string msg = "session\n";
foreach(XmlAttribute att in sessions[j].Attributes)
{
msg += att.Name + att.Value + "\n";
}
MessageBox.Show(msg);
}
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
----------------------------------------------------------
In addition, here are some tech references on the XmlNodeList and
XmlDocument's SelectNodes method in MSDN:
#XmlNode.SelectNodes Method (String)
http://msdn.microsoft.com/library/en...xmlxmlnodeclas
sselectnodestopic1.asp?frame=true
#Select Nodes Using XPath Navigation
http://msdn.microsoft.com/library/en...ctnodesusingxp
athnavigation.asp?frame=true
#XML Document Object Model (DOM)
http://msdn.microsoft.com/library/en...ocumentObjectM
odelDOM.asp?frame=true
Please check out the above items to see whether they help.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx