Hi,
I am having trouble with creation of XML programmaticall y using .NET. Specifically Im trying to create an element which looks like below and insert into an existing xml doc:
<Worksheet ss:Name="TKCShe et1">
</Worksheet>
The existing xml doc is:
<?xml version="1.0"?>
<?mso-application progid="Excel.S heet"?>
<Workbook xmlns="urn:sche mas-microsoft-com:office:spre adsheet"
xmlns:o="urn:sc hemas-microsoft-com:office:offi ce"
xmlns:x="urn:sc hemas-microsoft-com:office:exce l"
xmlns:ss="urn:s chemas-microsoft-com:office:spre adsheet"
xmlns:html="htt p://www.w3.org/TR/REC-html40">
</Workbook>
I had no problem using LoadXml() to read this existing xml into m_XmlDoc.
But the code I am using for creating that Worksheet node (as explained above):
// add new worksheet xml node at the end of the document
XmlElement wsNode = m_XmlDoc.Create Element("Worksh eet");
XmlAttribute wsName = m_XmlDoc.Create Attribute("ss:N ame");
//XmlAttribute wsName = m_XmlDoc.Create Attribute("ss", "Name", XmlNsMgr.Lookup Namespace("ss") ); //- this did not work either :(
wsName.Value = ?TKCSheet1?;
wsNode.Attribut es.Append(wsNam e);
m_XmlDoc.Docume ntElement.Appen dChild(wsNode);
But this code gives me:
<Worksheet Name="TKCSheet1 " xmlns="">
</Worksheet>
I want ss:Name NOT just Name, in my xml and also I do NOT want xmlns="" in that element!
Can somebody please help me out here?
Thanks,
Krishna
PS: I know probably using Excel 2003 .NET libraries might be cleaner, but I have limited to get this thing running.
--------------------------------
From: Krishna Tulasi
-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>tq30o75pHke +OTwMr4tQXQ==</Id>