![]() |
.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: Ne znam XML pa mi ovo nije jasno, ali mi zbog ovoga xmlns="" dokument nije validan! Dali mi netko može pomoći? |
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