473,394 Members | 1,709 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

System.XML Migration - Corresponding System.XML object for MSXML IXMLDOMSelection

Hi there,

I was trying to convert the following VB6 code to VB.NET. But I can't find
a corresponding System.XML object for MSXML IXMLDOMSelection.

I am thinking to use System.XML XMLNodeList object and GetElementsByTagName
method
to find the "selection". Any suggestion/comment?

Thanks in advance.

Abel

Example:
---------------------------------------------------------------
Dim xmlStatic As New MSXML2.DOMDocument
xmlStatic.loadXML (strXMLString)

Dim objSelection As IXMLDOMSelection
Set objSelection = xmlStatic.selectNodes("//Reading")

For i = 0 To objSelection.length - 1
....
next i

....
---------------------------------------------------------------

Nov 12 '05 #1
3 4851
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

Nov 12 '05 #2
Yes, you are correct on COM component.

I think your suggested XmlNodeList and SelectNodes should work.

By the way, do you have a copy of Side-By-Side MSXML to System.XML
Reference?

I can't find it anywhere in MS or in the WEB.

Thanks a lot.

Abel.


"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:6H*************@cpmsftngxa06.phx.gbl...
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

Nov 12 '05 #3
Hi Abel,
Thanks for your response. As for the "copy of Side-By-Side MSXML to
System.XML Reference", I've searched the MSDN and other reference but
didn't find any very detailed mapping lists. However, there is a kb article
below discussing on implement common MSXML task using SYSTEM.XML namespace
classes in dotnet

#HOW TO: Implement Common MSXML Tasks in System.xml By Using Visual C# .NET
http://support.microsoft.com/?id=330589

Hope this helpful.
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

Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Todd | last post by:
I'm having trouble porting something from VB 6.0 with MSXML 4.0 to C# and the .Net framework. Using MSXML 4.0, I use the HTTPRequest object to get the following page and obtain a list of...
2
by: Keith Chadwick | last post by:
I am current in the process of converting an existing ASP application to ASP.NET. The existing application makes extensive use of server side XML transformations as in ...
3
by: Steve | last post by:
Is there any way of specifying the startMode when using the xslTransform class? We are updating code which used msxml to the system.xml classes but can find no way to specify the startMode. We...
3
by: Marius Trælnes | last post by:
Hello! Is it possible to use system.xml classes in Internet Explorer? I wonder about this because we have an application that depends very much on msxml on the client, using data islands,...
1
by: jd | last post by:
I have an xsl file to generate xml in to an html file. The size of the xsl is 300kb and size of the xml is 47 kb (the size of xml is variable). I am using VB.net to convert the xml file into an...
3
by: Eugen Gulinsky | last post by:
Hello guys, I am having problems trying to migrate our MSXML4-compatible stylesheets containing large msxsl:script blocks to a formate understandable by System.Xml:Xsl.XslTransform. I keep...
2
by: KJS | last post by:
Hello, I'm receiving: 'System.Xml.Xsl.XsltException: Missing mandatory attribute 'version' After I try and run my transformation. I spent a good few days coming up with the appropriate (I think)...
1
by: MLH | last post by:
I want to change my system time date each time an A97 app is started. Here's how I've been doing it. Am looking for a better way. Sure some of you have researched this. Function...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.