473,387 Members | 1,596 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

read CDATA section in XML with XDocument?

Hi,

How would I edit the code below to read XML CData text?

Thanks,
Viepia

XDocument connectedPCsXML = XDocument.Load(new
StreamReader(Registry.GetValue(@"HKEY_LOCAL_MACHIN E\software\myCompany\configDir",
"path",@"C:\ConfigDir\") + "ConnectedPCs.xml"));
var PCs = from PC in connectedPCsXML.Descendants("ConnectedPC")
select new
{
Name = PC.Element("Name").Value,
IP = PC.Element("IP").Value,
Description = PC.Element("Description").Value,
DnsName = PC.Element("DnsName").Value
};
Aug 17 '08 #1
2 13297
On Aug 18, 3:10*am, viepia wrote:
Hi,

* *How would I edit the code below to read *XML CData text?

Thanks,
Viepia

* * * * * * XDocument connectedPCsXML = XDocument.Load(new
StreamReader(Registry.GetValue(@"HKEY_LOCAL_MACHIN E\software\myCompany\conf*igDir",
"path",@"C:\ConfigDir\") + "ConnectedPCs.xml"));
* * * * * * var PCs = from PC in connectedPCsXML.Descendants("ConnectedPC")
* * * * * * * * * * * select new
* * * * * * * * * * * {
* * * * * * * * * * * * * Name = PC.Element("Name").Value,
* * * * * * * * * * * * * IP = PC.Element("IP").Value,
* * * * * * * * * * * * * Description = PC.Element("Description").Value,
* * * * * * * * * * * * * DnsName = PC.Element("DnsName").Value
* * * * * * * * * * * };
Where is CData section?? Please post the query little clearly

-Cnu
Aug 18 '08 #2
viepia wrote:
How would I edit the code below to read XML CData text?
XDocument connectedPCsXML = XDocument.Load(new
StreamReader(Registry.GetValue(@"HKEY_LOCAL_MACHIN E\software\myCompany\configDir",
"path",@"C:\ConfigDir\") + "ConnectedPCs.xml"));
var PCs = from PC in connectedPCsXML.Descendants("ConnectedPC")
select new
{
Name = PC.Element("Name").Value,
IP = PC.Element("IP").Value,
Description = PC.Element("Description").Value,
DnsName = PC.Element("DnsName").Value
};
For your query with e.g. PC.Element("Description").Value it should not
make a difference whether the XML looks like e.g.
<Description>foo &amp; bar</Description>
or
<Description><![CDATA[foo & bar]]></Description>
the Value of the 'Description' remains the same.

If that does not help then show us the relevant XML.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Aug 18 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Xah Lee | last post by:
what does it mean when a style tag gives something like the following? <style type="text/css" media="screen,projection">/*<!]>*/</style> is this standard? Xah xah@xahlee.org ∑...
6
by: Cade Perkins | last post by:
How can the CDATA ending delimiter "]]>" be represented within a CDATA section itself? Consider an XML document that is intended to contain an embedded, uninterpreted XML example. Generally,...
4
by: Rich Wallace | last post by:
Hi all, I have an XML document fed to me from a third party app: <?xml version="1.0" encoding="WINDOWS-1252" ?> <GatewayPlan xmlns:xsd="http://www.w3.org/2001/XMLSchema"...
10
by: Jon Noring | last post by:
Out of curiosity, may a CDATA section appear within an attribute value with datatype CDATA? And if so, how about other attribute value datatypes which accept the XML markup characters? To me,...
10
by: Simon Brooke | last post by:
Here's my problem: <xsl:template match="/category"> .... <script type="text/javascript"> &lt;!]&gt; </script> .... </xsl:template>
11
by: ericms | last post by:
Can anybody show me how to insert a CDATA section using XPathNavigator ? I have tried the follwing with no luck: XmlDocument docNav = new XmlDocument(); docNav.LoadXml(xmlString);...
1
by: soccerdad | last post by:
I've got a class hierarchy generated from a .xsd schema file using the XSD.EXE tool. One of the elements will have its "inner text" set to a CDATA block. The XSD.EXE tool exposed a "Value" property...
2
by: Pugi! | last post by:
Using AJAX I want to send some information from the server (php-page) as XML to the client. The contents can be very divers so I have to use XML instead of text. On one occasion the contents is...
18
by: sim.sim | last post by:
Hi all. i'm faced to trouble using minidom: #i have a string (xml) within CDATA section, and the section includes "\r\n": iInStr = '<?xml version="1.0"?>\n<Data><!]></Data>\n' #After i...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.