PC Ekspert Forum

PC Ekspert Forum (https://forum.pcekspert.com/index.php)
-   Web dizajn, programiranje i ostalo (https://forum.pcekspert.com/forumdisplay.php?f=39)
-   -   .NET i XML problem (https://forum.pcekspert.com/showthread.php?t=146248)

ninoid 28.04.2009. 20:18

.NET i XML problem
 
Ljudi dali mi netko može pomoći da mi se u dokument na kraj elementa ne dodaje xmlns=""

Primjer: imam spreman XML file koji izgleda ovako:





Kreiram novi XDocument iz te datoteke: xd = XDocument.Load("Poruka0.xml");

zatim unutar poruke dodajem novi element sa potrebnim atributima:

_xd.Root.Add(
new XElement("PAKET",
new XAttribute("IDpaketa", ""),
new XAttribute("br_naloga", ""),
new XAttribute("suma", ""))
);

i nakon toga mi dokument izgleda ovako:



xmlns="" />


Ne znam XML pa mi ovo nije jasno, ali mi zbog ovoga xmlns="" dokument nije validan!

Dali mi netko može pomoći?

markaV 01.05.2009. 01:25

CODE:
---------
XDocument doc =
new XDocument(
new XElement("TrivadisLocations",
new XElement("Location",
new XAttribute("City","Basel"),
new XElement("Consultants",
new XElement("Consultant",
new XAttribute("FirstName", "Thomas"),
new XAttribute("LastName", "Huber")
),
new XElement("Consultant",
new XAttribute("FirstName", "Christoph"),
new XAttribute("LastName", "Pletz")
)
)
),
new XElement("Location",
new XAttribute("City", "Freiburg"),
new XElement("Consultants",
new XElement("Consultant",
new XAttribute("FirstName", "Thomas"),
new XAttribute("LastName", "Wukasch")
)
)
),
new XElement("Location",
new XAttribute("City","Zürich"),
new XElement("Consultants",
new XElement("Consultant",
new XAttribute("FirstName", "Patrick"),
new XAttribute("LastName", "Spieler")
)
)
)
)
);

doc.Save("locations.xml");

REZULTAT
-----------




















Sva vremena su GMT +2. Sada je 19:25.

Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© 1999-2024 PC Ekspert - Sva prava pridržana ISSN 1334-2940
Ad Management by RedTyger