?
Solved

Xml nested

Posted on 2004-10-10
3
Medium Priority
?
215 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

764 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