Solved

asp.net c# xml

Posted on 2014-11-10
1
83 Views
Last Modified: 2014-11-20
Below within if statement. How can I just read metaKyword?

 using (XmlTextReader reader = new XmlTextReader(Server.MapPath("Content/Website.xml")))
            {
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Text)
                    {
                       
                            Response.Write(reader.Value);
                            Response.Write("<br>");
                       
                    }
                }
            }



<?xml version="1.0" encoding="utf-8"?>
<Website>  
  <metaKeywords>Keywords In Details</metaKeywords>
  <metaDescription>Decription In Details</metaDescription>
</Website>
0
Comment
Question by:ITsolutionWizard
1 Comment
 
LVL 5

Accepted Solution

by:
Ronak Patel earned 500 total points
ID: 40434349
Hi,

Refer below code.. it is possible using "XmlDocument".

XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Server.MapPath("Content/Website.xml"));

XmlNode xmlNode = xmlDoc.SelectSingleNode("Website").SelectSingleNode("metaKeywords");

Response.Write(xmlNode.InnerText);

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now