473,325 Members | 2,872 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,325 software developers and data experts.

Finding & Updating nodes within a CDATA section

2 1705
BlankThe CDATA section is "hiding" the embedded XML so you will have to extract this out. THe following example prints the ipAddress "10.0.0.1":
using System;
using System.Text;
using System.Xml;

class Program {
static void Main(string[] args) {
XmlDocument doc = new XmlDocument();
doc.Load(@"..\..\xmlfile1.xml");

XmlNode sr = doc.SelectSingleNode("//ServiceRequest");

string innerXml = sr.InnerText;
doc.LoadXml(innerXml);

XmlNode addr = doc.SelectSingleNode("/DiscoverRequest/properties/property[@key='ipAddress']/@value");
Console.WriteLine(addr.InnerText);

}
}

Chris.

"Paul J Lay" <pj***@msn.com> wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl...
I seem to be able to find and update nodes and attributes fairly well using the XmlDocument class thanks the great support I received on this newgroup. However, I a can't seem to locate properties contained with a CDATA section. Is this possible? I have attached a small example. Thanks for your help.

Best Regards,

Paul J. Lay

Nov 12 '05 #2
Hi Paul,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to find and update certain
nodes in an xml document within a CDATA element of another xml document. If
there is any misunderstanding, please feel free to let me know.

In this case, since an Xml document is nesting in another one, we cannot
modify the properties in the CDATA element directly. Because all the data
within this section is regarded as string. So we need to do the following
steps to manipulate on the inner xml document.

1. Load the whole doc into an XmlDocument object.
2. Locate the CDATA element and get its content as a string.
3. Load the string into another XmlDocument object.
4. modify the doc and get the changed string and set it back to the CDATA
element.

Thus, the whole doc is updated. HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #3

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

Similar topics

3
by: wenke | last post by:
Hi, I am using the following code (see below) from php.net (http://www.php.net/manual/en/ref.xml.php, example 1) to parse an XML file (encoded in UTF-8). I changed the code slightly so that the...
2
by: Donald Firesmith | last post by:
I am having trouble having Google Adsense code stored in XSL converted properly into HTML. The <> unfortunately become &lt; and &gt; and then no longer work. XSL code is: <script...
4
by: webdev | last post by:
lo all, some of the questions i'll ask below have most certainly been discussed already, i just hope someone's kind enough to answer them again to help me out.. so i started a python 2.3...
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,...
2
by: Damon | last post by:
I'm getting errors using XML deserialisation and CDATA sections when there are hexidecimal characters involved. If the CDATA section does not contain a hexidecimal values everything is fine....
5
by: Newbie | last post by:
The answer to this is probably obvious, but I'm somewhat new to XSLT and can't find it. I need to sort a set of nodes within a document, e.g. <A> <B/> <C> <D>3</D> <D>2</D>
0
by: grant.trevor | last post by:
I have a need to define a regular expression within a custom configuration section. This can reside within a web.config or other .config file. Looking at the config below you can see the general...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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...
1
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...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.