---
title: "Läsa en xml fil i en textbox"
type: "forum-thread"
url: "https://www.webforum.nu/amne/dotnet/74754-läsa-en-xml-fil-i-en-textbox/page2"
topic: ".NET"
topic_url: "https://www.webforum.nu/amne/dotnet"
author: "wwwstekaren"
published: "2003-04-23T08:51:17.000Z"
updated: "2003-04-23T12:20:01.000Z"
replies: 26
views: 540
page: 2
pages: 2
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/dotnet/74754-läsa-en-xml-fil-i-en-textbox"
---

# Läsa en xml fil i en textbox

_Sida 2 av 2._

## #21 — NETwork, 2003-04-23T11:47Z

c# gör skillnad på små och stora bokstäver, du måste skriva Server.MapPath exakt så om du inte har gjort det. Fast du borde få ett annat felmeddelande då förstås... hm?

Permalänk: https://www.webforum.nu/p/1022877

## #22 — wwwstekaren, 2003-04-23T11:49Z

tack för dina snabba svar

Felen

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.IO.FileNotFoundException: Could not find file "C:\\WINNT\\system32\\webs.xml".

annars ser hela min cs kod ut så här:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Xml;

namespace listaxml
{
	/// \<summary\>
	/// Summary description for WebForm1.
	/// \</summary\>
	public class WebForm1 : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.ListBox ListBoxContacts;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// Put user code to initialize the page here
			if (!(Page.IsPostBack))
			{
				myFunction();
			}
		}
		protected void myFunction() 
		{
			// fylla din listbox
			XmlTextReader reader = new XmlTextReader(Server.MapPath("webs.xml"));
			while (reader.Read())
			{
				// Adda varje namn till din listbox
				
				Response.Write(reader.Value + "\<br\>");
		
			}

		}

		\#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// \<summary\>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// \</summary\>
		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);

		}
		\#endregion
	}
}

Permalänk: https://www.webforum.nu/p/1022878

## #23 — wwwstekaren, 2003-04-23T11:53Z

det som jag också får fel på är min function. .NET säger no overload for method 'myfunction' takes '0' arguments

Permalänk: https://www.webforum.nu/p/1022884

## #24 — wwwstekaren, 2003-04-23T11:59Z

hittar ej xml filen sökvägen stämmer inte:(

Permalänk: https://www.webforum.nu/p/1022886

## #25 — NETwork, 2003-04-23T12:05Z

Exakt var har du din xml-fil? Ligger den i rooten på din applikation (för det är där den ska söka nu)? 

Vad får du ut om du skriver Response.Write(Server.MapPath("")); i pageload?

Permalänk: https://www.webforum.nu/p/1022891

## #26 — wwwstekaren, 2003-04-23T12:13Z

nu funkar det, kom på själv att jag inte hade includerat using System.Xml.XPath; tack för all hjälp. Nu ska jag bara försöka att få in xml filen i listboxen

Permalänk: https://www.webforum.nu/p/1022895

## #27 — wwwstekaren, 2003-04-23T12:20Z

Nu funkar allt, tack för hjälpen alla:) Nu ska jag bara snygga till listan:)

Permalänk: https://www.webforum.nu/p/1022899

---

Tråden på webben: https://www.webforum.nu/amne/dotnet/74754-läsa-en-xml-fil-i-en-textbox/page2  
Föregående sida: https://www.webforum.nu/amne/dotnet/74754-läsa-en-xml-fil-i-en-textbox.md
