Thread: a XML question with MSXML

  1. #1
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    310

    Question a XML question with MSXML

    This is my xml file:
    Code:
    <?xml version='1.0' encoding='UTF-8' standalone='yes'?>
    <installers>
    	<installer id='1' size='1.6' sizetype='MB'>
    		<name>Windows Installer for Windows</name>
    		<version>2.0</version>
    		<os>Win9xMe</os>
    		<url>http://download.microsoft.com/download/WindowsInstaller/Install/2.0/W9XMe/EN-US/InstMsiA.exe</url>
    	</installer>
    	<installer id='2' size='1.0' sizetype='MB'>
    		<name>SSE Setup</name>
    		<version>4.0</version>
    		<os>Win9xMe2kXP</os>
    		<url>http://www.ssesetup.com/downloads/SSESetup40.exe</url>
    	</installer>
    	<installer id='3' size='1.4' sizetype='MB'>
    		<name>SSE Setup</name>
    		<version>2.17</version>
    		<os>Win9xMe2kXP</os>
    		<url>http://puzzle.dl.sourceforge.net/sourceforge/nsis/nsis-2.17-setup.exe</url>
    	</installer>
    </installers>
    How can I read only the the element <b>version</b> of the first node? Note that 3er party application or even the user can change the position or edit this element.

    Right now I use this:
    Code:
    pDoc->getElementsByTagName("installer")->Getitem(0)->childNodes->Getitem(1)->text
    But, as I said, it can be modified by externals.
    Thanks
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

  2. #2
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401
    Why not call getElementsByTagName("installer")->Getitem(0)->getElementsByTagName("version")?
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    MSXML also comes with an XPath engine; you can use that.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    310
    Thanks...

    I discovered this one:
    Code:
    pDoc->getElementsByTagName("installer")->Getitem(1)->attributes->getNamedItem("version")->text;
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. another do while question
    By kbpsu in forum C++ Programming
    Replies: 3
    Last Post: 03-23-2009, 12:14 PM
  2. binary search tree and xml
    By sweets in forum C++ Programming
    Replies: 1
    Last Post: 03-16-2004, 04:21 PM
  3. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  4. XML and database ??
    By mellisa in forum Tech Board
    Replies: 14
    Last Post: 03-30-2003, 04:02 AM
  5. C++ XML Class
    By edwardtisdale in forum C++ Programming
    Replies: 0
    Last Post: 12-10-2001, 11:14 PM