473,219 Members | 1,951 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,219 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 4839
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...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.