Solved

Xml nested

Posted on 2004-10-10
3
213 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 500 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

Independent Software Vendors: 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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

737 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