Link to home
Start Free TrialLog in
Avatar of peterdungan
peterdunganFlag for Ireland

asked on

xmlwriter not recognised

Hi
I'm looking at an example use of the xmlwriter in .net 2.0.
When I compile the code shown, I get errors like

The type or namespace name 'XmlWriterSettings' could not be found (are you missing a using directive or an assembly reference?)      

Why is this happening please? Do I need to add a reference to the project?

Thanks
<%@ WebHandler Language="C#" Class="Handler" %>
 
using System;
using System.Web;
 
public class Handler : IHttpHandler {
 
    public void ProcessRequest(HttpContext context)
    {
        XmlWriterSettings settings = new XmlWriterSettings();
        settings.Indent = true;
 
        context.Response.ContentType = "text/xml";
 
        using (XmlWriter writer = XmlWriter.Create(context.Response.OutputStream, settings))
        {
            writer.WriteStartElement("slides");
            writer.WriteStartElement("slide");
            writer.WriteAttributeString("imageUrl", "foo.jpg");
            writer.WriteAttributeString("thumbnailUrl", "foo_thumb.jpg");
            writer.WriteAttributeString("caption", "this is a test");
            writer.WriteEndElement();
            writer.WriteEndElement();
        }
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }
 
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of peterdungan
peterdungan
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You will need:

using System.Xml;

at the beginning of your source code file, and also check the project References, as peter stated.
to be more specific, go to Menu -> Project -> Add Reference... -> .net tab
Check if System.Xml.dll reference is checked.
Avatar of peterdungan

ASKER

Yes thanks I realised that and posted the reply above.
sorry, not noticed, that you was the question's author.