Click here to Skip to main content
16,004,977 members
Home / Discussions / XML / XSL
   

XML / XSL

 
GeneralRe: Simple question to get attribute of IXMLDOMNode in using MSXML Pin
Michael A. Barnhart25-Feb-03 5:07
Michael A. Barnhart25-Feb-03 5:07 
GeneralFailed to CreateInstance while using IXMLHttpRequestPtr Pin
adapterJohn25-Feb-03 2:09
adapterJohn25-Feb-03 2:09 
GeneralRe: Failed to CreateInstance while using IXMLHttpRequestPtr Pin
Michael A. Barnhart25-Feb-03 5:00
Michael A. Barnhart25-Feb-03 5:00 
GeneralRe: Failed to CreateInstance while using IXMLHttpRequestPtr Pin
adapterJohn25-Feb-03 22:38
adapterJohn25-Feb-03 22:38 
QuestionClarification Regarding Compatiblity with Managed C++/CLI [modified] Pin
pix_programmer9-Mar-11 0:33
pix_programmer9-Mar-11 0:33 
GeneralWalking Through XML in JavaScript Visiting All ChildNodes Pin
Vasudevan Deepak Kumar21-Feb-03 18:15
Vasudevan Deepak Kumar21-Feb-03 18:15 
GeneralRe: Walking Through XML in JavaScript Visiting All ChildNodes Pin
palbano24-Feb-03 4:41
palbano24-Feb-03 4:41 
Generalproblem creating XML programatically Pin
illsorted19-Feb-03 6:36
illsorted19-Feb-03 6:36 
Hello all, this is my first project involving the use of XML data and I've run into a strange problem. First, here is the function I'm using to write a simple XML file:

/// Writes contents of reportData array to XML file.

public void writeXML() {
			
	XmlTextWriter xml = 
		new XmlTextWriter("c:\\test.xml", System.Text.Encoding.UTF8);
	xml.Formatting = Formatting.Indented;			

	xml.WriteStartDocument();

	int i, j, iMax, jMax;
	iMax = reportData.GetUpperBound(0);
	jMax = reportData.GetUpperBound(1);

	try {
		for (i = 0; i <= iMax; i++)  {
			xml.WriteStartElement("transaction");
			for (j = 0; j < jMax; j++) { // no <= on purpose: to skip validation column
				xml.WriteStartElement("item");

				if (reportData[i,j] != null) 
					xml.WriteString(reportData[i,j].ToString().Trim());

				xml.WriteEndElement();								
			}
			xml.WriteEndElement(); // end transaction
		}
		xml.WriteEndDocument();

	} catch (Exception ex) {
		System.Console.Write(ex.ToString()); // display exception details
		xml.Flush();
		xml.BaseStream.Flush();
	}

	xml.Close();
}

NOTE: reportData is a two-dimensional array of objects that contains information from a CSV/text file.

The problem is that this code throws an exception the second time through the outer loop at the line 'xml.WriteStartElement("transaction");'. This is strange to me because the first "transaction" element and its "item" children are created fine, but the second "transaction" element errors out. Am I missing something in the XML rules? Anyway, here is the exception information:
System.InvalidOperationException: Token StartElement in state Epilog would result in an invalid XML document.
   at System.Xml.XmlTextWriter.AutoComplete(Token token)
   at System.Xml.XmlTextWriter.WriteStartElement(String prefix, String localName, String ns)
   at System.Xml.XmlWriter.WriteStartElement(String localName)
   at MerchantReport.MerchantReport.writeXML() in d:\projects\bearcub\merchantreporttransformation\merchantreport\merchantreport.cs:line 290

and here is the XML document created after I flush the stream:
<?xml version="1.0" encoding="utf-8"?>
<transaction>
  <item>12345</item>
  <item>A</item>
</transaction>


Any help in finding the problem is greatly appreciated.
GeneralRe: problem creating XML programatically Pin
Philip Fitzsimons24-Feb-03 2:32
Philip Fitzsimons24-Feb-03 2:32 
GeneralDifferent between XSL and XSLT Pin
Firas Rashid17-Feb-03 2:05
Firas Rashid17-Feb-03 2:05 
GeneralRe: Different between XSL and XSLT Pin
Philip Fitzsimons19-Feb-03 1:58
Philip Fitzsimons19-Feb-03 1:58 
QuestionMy xml file is displayed as a long string. How do I insert newlines? Pin
lnong16-Feb-03 1:47
lnong16-Feb-03 1:47 
AnswerRe: My xml file is displayed as a long string. How do I insert newlines? Pin
Richard Deeming17-Feb-03 3:38
mveRichard Deeming17-Feb-03 3:38 
QuestionAm I creating an XML document correctly? Pin
lnong16-Feb-03 1:29
lnong16-Feb-03 1:29 
AnswerRe: Am I creating an XML document correctly? Pin
Philip Fitzsimons19-Feb-03 2:06
Philip Fitzsimons19-Feb-03 2:06 
QuestionHow to store XML content into C/C++ structure Pin
15-Feb-03 10:23
suss15-Feb-03 10:23 
AnswerRe: How to store XML content into C/C++ structure Pin
Nitron18-Feb-03 14:19
Nitron18-Feb-03 14:19 
AnswerRe: How to store XML content into C/C++ structure Pin
palbano19-Feb-03 12:22
palbano19-Feb-03 12:22 
GeneralRe: How to store XML content into C/C++ structure Pin
palbano19-Feb-03 12:24
palbano19-Feb-03 12:24 
GeneralXML Docs/Comments Pin
mgarwood15-Feb-03 6:42
mgarwood15-Feb-03 6:42 
GeneralI need your suggestion about storing data as XML Pin
lnong14-Feb-03 14:46
lnong14-Feb-03 14:46 
GeneralRe: I need your suggestion about storing data as XML Pin
Nitron18-Feb-03 14:24
Nitron18-Feb-03 14:24 
GeneralXML using C/C++ Pin
vietdynamite14-Feb-03 1:54
vietdynamite14-Feb-03 1:54 
GeneralRe: XML using C/C++ Pin
palbano14-Feb-03 5:04
palbano14-Feb-03 5:04 
GeneralRe: XML using C/C++ Pin
15-Feb-03 9:36
suss15-Feb-03 9:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.