Autor Beitrag
kostonstyle
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 94



BeitragVerfasst: Mi 20.01.10 15:51 
Hallo miteinander
habe eine Frage zu XML, zwar habe ich eine XML Datei verarbeitet, vor der Verarbeitung
sieht die Codierung so aus:
ausblenden XML-Daten
1:
<?xml version='1.0' encoding='ISO-8859-1' ?>					

nach der Verarbeitung
ausblenden XML-Daten
1:
<?xml version="1.0" encoding="utf-8"?>					

warum wird es geändert?

Danke kostonstyle

Moderiert von user profile iconChristian S.: XML-Tags hinzugefügt
JüTho
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2021
Erhaltene Danke: 6

Win XP Prof
C# 2.0 (#D für NET 2.0, dazu Firebird); früher Delphi 5 und Delphi 2005 Pro
BeitragVerfasst: Mi 20.01.10 17:22 
Woher sollen wir wissen, wer was wo wie verarbeitet? Meine Glaskugel sagt: Irgendwo bei der Verarbeitung wird zum Lesen etwas wie Encoding.Default (= Win1252) verwendet, aber zum Speichern kein Encoding (also UTF-8) angegeben. Jürgen

Moderiert von user profile iconChristian S.: Leertag zur Smily-Maskierung eingefügt
kostonstyle Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 94



BeitragVerfasst: Mi 20.01.10 17:30 
also, ich habe eine XML Datei eingelesen und bearbeitet, zum Beispiel ein Wert von Element XXXXX geändert.
So habe die XML Datei eingelesen
ausblenden C#-Quelltext
1:
2:
3:
XElement plu_xml = XElement.Load(file.FullName);
traverse_plu(plu_xml);
plu_xml.Save(file.FullName);

vor der verarbeitung sieht die Encodierung so aus
ausblenden XML-Daten
1:
2:
3:
4:
<?xml version='1.0' encoding='ISO-8859-1' ?>
<PLU>
 <longName></longName>
 <popUp></popUp>

nach der Verarbeitung bzw nach Save()
ausblenden XML-Daten
1:
2:
3:
4:
5:
<?xml version="1.0" encoding="utf-8"?>
<PLU>
  <longName></longName>
  <popUp></popUp>
  <pluParams>


Danke konststyle
danielf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1012
Erhaltene Danke: 24

Windows XP
C#, Visual Studio
BeitragVerfasst: Mi 20.01.10 18:35 
Warum verwendest du das XElement und nicht das XmlDocument?
Ich mein XmlDocument verwendet automatisch das geladene Format - und XElement kann ja auch nicht viel oder? :nixweiss:

Oder ist es wegen Performanz? :gruebel:

Gruß Daniel
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Mi 20.01.10 20:11 
user profile iconkostonstyle hat folgendes geschrieben Zum zitierten Posting springen:
So habe die XML Datei eingelesen
Wie es der Name schon sagt, ist XElement lediglich ein einzelnes XML-Element. Du brauchst XDocument, das speichert auch die XML-Deklaration.

user profile icondanielf hat folgendes geschrieben Zum zitierten Posting springen:
Warum verwendest du das XElement und nicht das XmlDocument?
Weil neuer & besser :P .
user profile icondanielf hat folgendes geschrieben Zum zitierten Posting springen:
und XElement kann ja auch nicht viel oder? :nixweiss:
Hu, was fehlt dir beispielsweise?
Siehe auch msdn.microsoft.com/e...ibrary/bb387021.aspx

_________________
>λ=
danielf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1012
Erhaltene Danke: 24

Windows XP
C#, Visual Studio
BeitragVerfasst: Do 21.01.10 09:40 
Ich sag nicht, dass was fehlt. Ich stelle mir nur die Frage warum umsteigen?

Ich bin mit XmlDocument glücklich ;)
kostonstyle Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 94



BeitragVerfasst: Do 21.01.10 10:00 
was soll ich jetzt nach eurer Meinung benutzen?
danielf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1012
Erhaltene Danke: 24

Windows XP
C#, Visual Studio
BeitragVerfasst: Do 21.01.10 10:36 
Zitat:

Zitat:

Warum verwendest du das XElement und nicht das XmlDocument?

Weil neuer & besser :P .


Du sollst wohl XDocument anstatt XElement verwenden, weil's besser ist :o
kostonstyle Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 94



BeitragVerfasst: Do 21.01.10 10:47 
Ok..vielen dank
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Do 21.01.10 23:52 
user profile icondanielf hat folgendes geschrieben Zum zitierten Posting springen:
Ich bin mit XmlDocument glücklich ;)
Ich will das nicht weiter ausführen, aber es soll auch Leute geben, die unter 1.1 noch mit ArrayList glücklich waren :nixweiss: .
Achja, schneller ist's anscheinend auch noch ;) .

_________________
>λ=