Click here to Skip to main content
11,802,389 members (30,876 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C#
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Origin X="0.117" Y="0.027"/>
<RegistrationMark TopLeftX="1.317" TopLeftY="2.043" TopRightX="7.100" TopRightY="2.047" BottomLeftX="1.313" BottomLeftY="3.073" BottomRightX="7.097" BottomRightY="3.077"/>
This is the generated xml in c#. In that
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
encoding="utf-8" standalone="yes"? i don't want this parameter how we can genarate xml with out this parameter. only i want
<?xml version="1.0"?>
like this
Posted 22-Dec-11 8:50am
Edited 22-Dec-11 9:13am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

All that does is defines the document.

XDocument doc = new XDocument();

I believe that if you don't specify a new XDeclaration, it will not set any of that stuff. My suggestions is to try the code above and loo at your file to see what's in it.
Wonde Tadesse at 22-Dec-11 18:45pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

The situation is directly opposite: I have no idea how you ended up with the "standalone" attribute in the XML prolog. I must confess I never faced with this "mysterious" (see below) attribute before, as all direct ways to produce XML found in the standard libraries won't produce this attribute, unless you intentionally create it, of course.

About this attribute and its use, please see[^].

By the way, I don't know why this attribute can do anything wrong. But of course, you have every right to avoid having it.

So, just in case, let me overview all standard methods of working with XML directly. Of course, this review does not include various forms of serialization (which you might have faces with) or Data Contract (which I always highly recommend). Let's see:

  1. Use System.Xml.XmlDocument class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.
  2. Use the classes System.Xml.XmlTextWriter and System.Xml.XmlTextReader; this is the fastest way of reading, especially is you need to skip some data.
  3. Use the class System.Xml.Linq.XDocument; this is the most adequate way similar to that of XmlDocument, supporting LINQ to XML Programming.

Wonde Tadesse at 22-Dec-11 18:45pm
SAKryukov at 22-Dec-11 19:13pm
Thank you, Wonde.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 475
1 KrunalRohit 366
2 F-ES Sitecore 295
3 Afzaal Ahmad Zeeshan 230
4 CHill60 220
0 OriginalGriff 2,950
1 Maciej Los 1,910
2 KrunalRohit 1,862
3 CPallini 1,645
4 Richard MacCutchan 1,157

Advertise | Privacy | Mobile
Web03 | 2.8.151002.1 | Last Updated 22 Dec 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100