Autor Beitrag
derprogrammier69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Mi 29.01.14 13:11 
Hi meine neuen Freunde :) ,
habe ein kleines Problemchen und iwie keinen Ansatz :(
Die Aufgabe besteht darin, ein Zielformat einer XML-Datei zu verändern:

ausblenden XML-Daten
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
[...]
  <OrderItems>
    <OrderItem>
      <ItemName>Playstation 4</ItemName>
      <Description>Beste Konsole zur Zeit auf dem Markt.</Description>
      <UnitPrice>499</UnitPrice>
      <Quantity>1</Quantity>
    </OrderItem>
    <OrderItem>
      <ItemName>PS4 Controller</ItemName>
      <Description>Echt ergonometrisch.</Description>
      <UnitPrice>59</UnitPrice>
      <Quantity>2</Quantity>
    </OrderItem>
  </OrderItems>
[...]



-> daraus soll von Gebrauch von XML-Attributen folgendes werden:
msdn.microsoft.com/d...3e%28v=vs.90%29.aspx (hier findet ihr die Attribute)

ausblenden XML-Daten
1:
2:
3:
4:
5:
6:
[...]
<Items>
<Item ItemName="PS4" Description="Beste Konsole zur Zeit auf dem Markt." UnitPrice="499" Quantity="1">
<Item ItemName="PS4 Controller" Description="Echt ergonometrisch." UnitPrice="59" Quantity="2">
</Items>
[...]


Vielen Dank für schnelle und kompetente Hilfe. MFG Peta

Moderiert von user profile iconChristian S.: XML-Tags hinzugefügt
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mi 29.01.14 13:15 
Und was ist jetzt die Frage? :gruebel:

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
derprogrammier69 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Mi 29.01.14 13:49 
Hi,
meine Frage ist, was ich vor public OrderItem[]... für ein (evtl. mehrere) XML-Attribut (in der Art wie z.B. [XmlAttribute]) setzen muss, damit sich die obere XML-Version in die untere verwandelt...

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
public class PurchaseOrder
        {
            public Address ShipTo;

            [XmlAttribute] //so wandert das XML-Element "OrderDate" als XML-Attribute in die Titelzeile
            public String OrderDate; 

            public OrderItem[] OrderItems = new OrderItem[2]; //hier nur zum Testen 2 OrderItems im Array
            public decimal ShipCost;


MFG

Moderiert von user profile iconChristian S.: C#-Tags hinzugefügt
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mi 29.01.14 14:03 
Wie ein OrderItem serialisiert wird, wird in der Klasse OrderItem bestimmt. Das heißt wenn die Properties / Felder als XML-Attribute serialisiert werden, musst Du dort die entsprechenden C#-Attribute vor die Properties / Felder setzen.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Ralf Jansen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 4701
Erhaltene Danke: 991


VS2010 Pro, VS2012 Pro, VS2013 Pro, VS2015 Pro, Delphi 7 Pro
BeitragVerfasst: Mi 29.01.14 14:06 
Das Naming der Tags über XMLArray und XMLArrayItem und der Rest durch Attributieren in der OrderItem Klasse. Mit dem von dir schon angedeuteten XmlAttribute Attribute.
derprogrammier69 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Mi 29.01.14 14:10 
Danke schonmal für die Antwort, probiere das heute Abend mal aus und melde mich dann nochmal! MFG
derprogrammier69 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Do 30.01.14 15:43 
hi, wieder vielen dank für die tips, hab exakt die gewünschte ausgabe erhalten. mfg