XmlTextWriter

This is a discussion on XmlTextWriter within the C# Programming forums, part of the General Programming Boards category; Code: // using System; using System.Drawing; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Xml; // pDoc = new XmlDocument(); XmlProcessingInstruction pPI = ...

  1. #1
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    308

    XmlTextWriter

    Code:
    //
    using System;
    using System.Drawing;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;
    using System.Xml;
    //
    pDoc = new XmlDocument();
    		XmlProcessingInstruction pPI = pDoc.CreateProcessingInstruction("xml", "version='1.0' encoding='ISO-8859-1'");
    		pDoc.AppendChild(pPI);
    		XmlTextWriter writer = new XmlTextWriter("boop.xml", null);
    		writer.Formatting = Formatting.Indented;
    		pDoc.Save(writer);
    		writer.Flush();
    Why the above code generates an error of XmlTextWriter?
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    What error?

    (The reason is that the XML declaration is not a processing instruction. Read the XML spec.)
    But when you get an error, you should still post it.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    308
    Thanks... i read some tutos and seems that main error is that I don't have a root element.
    Fixed

    I would post the error, but I have the .NET SDK in spanish and the debugger dumps all in spanish.
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21