473,241 Members | 1,434 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,241 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 13279
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.