עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

עזרה בC# עם XML

Featured Replies

פורסם

אהלן.

אני מנסה ליצור ולשלוח קבצי XML דרך הרשת, השליחה וכל הנלווה לה מתבצעים בסדר.

אבל התכנית זורקת אותי כשאני מנסה לפענח את הקובץ באקספשן הזה :There is an error in XML document (1, 1).

קטע הקוד של המחלקה המטפלת בקבצי XML:





using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.IO;
using System.Xml;
using Data;


namespace XMLHandler
{
public static class XMLHandler
{
public static string Serialize(string path, Data.Data d)
{
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
path = path + @"\Save.xml";


XmlDocument xmlDoc = new XmlDocument();
FileStream stream = File.Open(path, FileMode.Create, FileAccess.Write);
XmlSerializer serializer = new XmlSerializer(typeof(Data.Data));
serializer.Serialize(stream, d);
stream.Close();


return path;
}


public static Data.Data Deserialize(string path, byte[] data)
{
if (!Directory.Exists(path))
Directory.CreateDirectory(path);


string newPath = path + "\\test.xml";


FileStream file = new FileStream(newPath, FileMode.Create);
file.Write(data, 0, data.Length);
file.Flush();
file.Close();


file = new FileStream(newPath, FileMode.OpenOrCreate);
XmlSerializer sr = new XmlSerializer(typeof(Data.Data));
Data.Data d = (Data.Data)sr.Deserialize(file);
file.Close();
return d;
}




}
}


בדקתי בתיקיה וקובץ הXML אכן נוצר כראוי.

  • 2 שבועות מאוחר יותר...
פורסם

כי בפענוח אתה דורס את התוכן של הקובץ ורושם לתוכו את המערך data ואז אתה מנסה לפענח את הקובץ הזה שמכיל את מה ש-data הכיל. למה אתה עושה את זה? מה המערך הזה אמור לייצג?

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.