all groups > dotnet xml > may 2004 >
You're in the

dotnet xml

group:

printing out :


printing out : MFRASER
5/14/2004 2:27:13 PM
dotnet xml: Ok. I am new to the DOM document idea. I previously just created my XML
using a textbuilder or string object.

Now I am trying to create the XML in a string format, send the XML to
another object , and rebuild the DOM inside the object.

Here is my code pay attention to the last five lines.
//Start building XMLDocument

private string CovertObjectString(MyObject MyObject)

{

System.Xml.XmlDocument XMLDoc = new System.Xml.XmlDocument();

System.Xml.XmlNamespaceManager nsManager = new
System.Xml.XmlNamespaceManager(XMLDoc.NameTable);


nsManager.AddNamespace("dd", "http://acme.com/Data.xsd");

nsManager.AddNamespace("vi", "http://acme.com/Value.xsd");

nsManager.AddNamespace("wp", "http://acme.com/WeeklyData.xsd");

try

{

//get the root information from base

//Get Patthern ID

//Create Values Element

System.Xml.XmlNode XMLValuesNode =
XMLDoc.CreateElement("wp:Values");


//Create Value Element add to values

System.Xml.XmlNode XMLValue = XMLDoc.CreateElement("Value");

.....



XMLValuesNode.AppendChild(XMLValue);



//Append Data to XMLDocument

XMLDoc.AppendChild(XMLValuesNode);


}

catch{}

//I need to do the following for the wp: to appear this doesn't seem
right.

System.Text.StringBuilder retVal = new
System.Text.StringBuilder(XMLTP.OuterXml + XMLDoc.OuterXml.ToString());

retVal.Replace("<Values", "<wp:Values");

retVal.Replace("</Values", "</wp:Values");

return retVal.ToString();

}

Re: printing out : Martin Honnen
5/15/2004 12:29:26 PM


[quoted text, click to view]

It doesn't make much sense to use simple string processing for the
transformation of one XML format to another if there are more
appropriate tools like XSLT to do that. Consider looking into XSLT to
make that transformation from a null namespace to the
http://acme.com/WeeklyData.xsd namespace, see
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconxslttransformationswithxsltransformclass.asp


--

Martin Honnen
http://JavaScript.FAQTs.com/
AddThis Social Bookmark Button