Link to home
Start Free TrialLog in
Avatar of silentthread2k
silentthread2kFlag for United States of America

asked on

Modify CDATA attribute in XmlDocument without using Navigator or XPath

The code below works if I want to modify the information inside the tag, but how do I modify the CDATA for what looks to be an attribute?

I want to modify "DocInfo" CDATA, but can't seem to find the correct expression to place into SelectSingleNode function.

(see below code and sample input xml.)


using System.Xml;

XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(xmlfilepath);
xmldoc.SelectSingleNode("Document/DocumentName").InnerText = "test";



<?xml version="1.0" encoding="utf-8" ?>
<Document>
  <DocumentName><![CDATA[]]></DocumentName>
  <IndexCollection>
    <Index columnname="DocInfo"><![CDATA[]]></Index>
    <Index columnname="Somethingelse"><![CDATA[]]></Index>
  </IndexCollection>
</Document>
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial