Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Xml nested

Posted on 2004-10-10
3
Medium Priority
?
217 Views
Last Modified: 2010-04-15
Hello,

i have got a XML File like this:

<?xml version="1.0" standalone="yes"?>
<Core>
  <Entries>
    <Name>Sample</Name>
    <Link>www.test.org</Link>
    <Comments>
      <Name>localhorsti</Name>
      <Text />
    </Comments>
  </Entries>
  <Entries>
    <Name>k</Name>
    <Link>www.sample.com</Link>
    <Comments>
      <Name>username</Name>
      <Text />
    </Comments>
    <Comments>
      <Name>author</Name>
      <Text />
    </Comments>
  </Entries>
</Core>

and now i want to get all the 'Comment' rows of the second 'Entries' row and set it to a DataSource.

How to do that ?
Thanks, Manuel
0
Comment
Question by:MLeandroK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 10

Accepted Solution

by:
Hans Langer earned 2000 total points
ID: 12273770
Hi,
use Xpath = "/Core/Entries/Comments[2]"

This is a exelent site of examples of XPath, take a look.
http://www.zvon.org/xxl/XPathTutorial/Output/example1.html

Other Way is use System.Xml.XmlDocument Class

XmlDocument xmldoc = new XmlDocument
xmldoc.load("YourXmlFile.xml")
xmldoc.SelectNodes("/Core/Entries/Comments").Item(1) or  xmldoc.SelectSingleNode("/Core/Entries/Comments[2]")
xmldoc.SelectSingleNode("/Core/Entries/Comments[2]").InnerXml <- Return Xml Node as string

GL
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question