473,395 Members | 1,653 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,395 software developers and data experts.

Using MSXML and C++to get all children?

BCC
Hi,

I am new to msxml, and am having a hard time figuring out how to get all
children of a particular node. For example, if I have something like this:
<?xml version="1.0" encoding="utf-8"?>
<rules>
<cell id="1">
<type>CD4 Cell</type>
<x>10</x>
<y>10</y>
<z>2</z>
<is_static>false</is_static>
</cell>
<cell id="2">
<type>CD4 Cell</type>
<x>10</x>
<y>10</y>
<z>4</z>
<is_static>false</is_static>
</cell>
<cell id="3">
<type>CD4 Cell</type>
<x>10</x>
<y>10</y>
<z>6</z>
<is_static>false</is_static>
</cell>
</rules>

I need to return a list of some sort that I can iterate through so I can
create a new 'cell' object for each cell in the list and initialize it in
the parameters given in the xml file (x, y, z, is_static, whatever). I can
read in the file okay, and have it stored as a CComPtr<IXMLDOMDocument2>
object (code I got from the web), but now Im at a loss as to how to parse it
and get what I need out.

Any suggestions, links or other helpful advice?

Thanks,
Bryan
Jul 20 '05 #1
1 1765


BCC wrote:

I am new to msxml, and am having a hard time figuring out how to get all
children of a particular node. For example, if I have something like this:
<?xml version="1.0" encoding="utf-8"?>
<rules>
<cell id="1">
<type>CD4 Cell</type>
<x>10</x>
<y>10</y>
<z>2</z>
<is_static>false</is_static>
</cell>
<cell id="2">
<type>CD4 Cell</type>
<x>10</x>
<y>10</y>
<z>4</z>
<is_static>false</is_static>
</cell>
<cell id="3">
<type>CD4 Cell</type>
<x>10</x>
<y>10</y>
<z>6</z>
<is_static>false</is_static>
</cell>
</rules>

I need to return a list of some sort that I can iterate through so I can
create a new 'cell' object for each cell in the list and initialize it in
the parameters given in the xml file (x, y, z, is_static, whatever). I can
read in the file okay, and have it stored as a CComPtr<IXMLDOMDocument2>
object (code I got from the web), but now Im at a loss as to how to parse it
and get what I need out.


If you load the file and already have an IXMLDOMDocument2 then the
document is parsed and you can now use the DOM API and the MSXML
specific XPath API to extract data or change it.
So your document object has a method named selectNodes for instance
which takes a string with an XPath expression e.g. (JScript syntax)
var nodeList = xmlDocument.selectNodes("/rules/cell")
The documentation for MSXML is here:
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/anch_xmlprod.asp>
Look at the members of IXMLDOMDocument2 and the examples there.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2

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

Similar topics

0
by: Punit | last post by:
Hi, Could someone please suggest where I am going wrong... Iam using MSXML 3.0 and VC++ but i end up getting blank response XML try { hr =...
0
by: Daniel | last post by:
Are the differences between MSXML and .Net XSL transformation documented online anywhere? Many of my XSL's work in MSXML but transform differently in ..Net XSL transformation.
1
by: Eder de Oliveira | last post by:
So, MSXML 3.0 doesn't support Schema XSD. But where I can find especification about this? thanks Eder *** Sent via Developersdex http://www.developersdex.com *** Don't just participate...
19
by: Mark Miller | last post by:
QUESTION: Does anyone know how I can use v2.6 of the MSXML parser with .NET? BACKGROUND: I "Web to Print" process that allows our clients (newspapers) to export their data and pass it thru a...
6
by: Alfred Taylor | last post by:
I'm having performance/memory problems using .NET's XslTransform class so I thought I'd give the MSXML object's a whirl. The question I haven't been able to find in these groups is can I use C#...
1
by: Praveen | last post by:
How can I canonicalise an XML file in VB???? Kindly help me out at the earliest. I can do the same in .NET using System.Security.Cryptography.Xml.XmlDsigC14NTransform namespace. I am very much...
3
by: Sharon | last post by:
How can I find what MSXML version I have installed? -- Thanks Sharon
5
by: Jeroen | last post by:
We're using MSXML to transform the XML document we have to an XHTML file using an XSLT. Now the problem is that the dotnet implementation we made does something subtly different from the...
1
by: Mayur | last post by:
Hello All, My code below sending request to web server and getting response as XML string. char* response; wf.getResponse(response,500); where outout of above function returns xml string...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.