Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

adding XmlTextReader to an XmlDocument

Status
Not open for further replies.

Sniipe

Programmer
Oct 9, 2006
115
IE
hello all I hope you can help me out here. I have an xmlDocument xDoc with content in it already. I also have an xml file that I want to append to it. here is the function

Code:
private void addFooter(ref XmlDocument xDoc)
{
	// Get the footer xml document and add it to the 
    // current xDoc (Session["XMLParts"])
	string langDelimiter = Session["CurrentLanguage"].ToString().ToLower();
	string filename = Server.MapPath("Reports/FooterText_" + langDelimiter + ".xml");

	XmlTextReader reader = new XmlTextReader(filename);
			
	reader.MoveToContent(); //Move to the cd element node.
			
	//Create a node representing the footerText element node.
	XmlNode footerText = xDoc.ReadNode(reader);

	//Insert the new node into the document.
	xDoc.DocumentElement.AppendChild(footerText); 
}

The problem is that the footerText node above contains has innerXml like this:
"\r\n\t<section>\r\n\t\t<header>\r\n\t\t\tThis is the first header\r\n\t\t</header>\r\n\t\t<text>\r\n\t\t\tThis..." Then when I add it to the xDoc it keeps all the \r\n\t stuff... Any ideas?
 
would a simple find/replace work?
Code:
string.replace(reader.Text, new char[] {@'\t', @'\n',@'\r'}, new char[] {'','',''});

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top