xmlwriter

using C# WriteDocType() to generate Apple Property List-compliant XML

I'm trying to produce an XmlDocument which has a DocType as specified in Apple's Property List (P-List) format, which should look like this: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt; <plist version="1.0"> The code I have at the momen...

XMLWriter vs SimpleXML. Which one is faster?

I basicly need to load the whole XML file, add a new line with content and then saving it. But I wondered which one is faster.. XMLWriter or SimpleXML? Oh, and, it's mainly large XML files, more then 10MB. Thanks! ...

C# XMLWriter + prevent "/" "<" "<" chars

Hello, I have a xmlWriter and want to write String which containt chars of "/" "<" ">" (which are part of the xml syntax and break the xml code). Here is my c# code: public Boolean Initialize(String path) { Boolean result = true; XmlWriterSettings settings = new XmlWriterSettings(); settings.CheckCh...

writing xmlwriter contents to a linq to sql xelement field

I have a field in a table defined as xml so in my dbml it's showing up as an xelement. I have an xmlwriter in my class that needs to write it's xml to this field but calling tostring on the writer doesn't work. How do I assign the xmlwriter or it's contents to an xelement? Thanks. ...

Different way to d XMLWriter::writeRaw()

I use a PHP class called healthvaultphp which uses XMLWriter::writeRaw(). While my development server had PHP 5.2, when trying to "go live", I found out the production server has PHP 5.1.6, and won't be upgrdaded in the enar future. True, this is my fault not to verify the exact version, but the question is what can be the solution in t...

XmlWriter writing empty xmlns

I'm using the following code to initialise an XmlDocument XmlDocument moDocument = new XmlDocument(); moDocument.AppendChild(moDocument.CreateXmlDeclaration("1.0", "UTF-8", null)); moDocument.AppendChild(moDocument.CreateElement("kml", "http://www.opengis.net/kml/2.2")); Later in the process I write some values to it using the followi...

How to control prefixes of namespaces in XML document generated by XmlWriter - generated XAML with x:Type markup extension

I am trying to generate XAML from XElements. <Style xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&gt; <Style.BasedOn> <StaticResource> <StaticResource.ResourceKey> <Type xmlns="http://schemas.microsoft.com/winfx/2006/xaml"&gt; <Type.TypeName>p:Window</Type.TypeName> </Type> ...

How to write top-level XML element values after writing sub elements

I'm looking for advice here on a smart solution to my problem. I'm writing an XML Document using the XMLWriter class and reading data out of an ADO.NET DataReader in a forward-only fashion. In the top of my XML file I need to have elements like so: <datefrom>2010-07-08</datefrom> <dateto>2010-07-10</dateto> <total>335.00</total> <dat...

Avoid the carriage return when writing InnerText in xml elements using System.Xml.XmlWriter

Hi everyone, I'm using XmlWriter to save an XmlDocument in .Net. However all the elements that have InnerText are written with surrounding carriage return characters. I tried using XmlWriterSettings to avoid the writing of those characters, but no luck yet. Here it is a piece of code used: XmlDocument outXml = new XmlDocument...

XmlWriter - reading an attribute (quick question)

I'm using this for my code, it outputs to the xml file perfectly, but it adds an ' = ' sign after the element name even though only one of my elements has an attribute. I suppose I could do something like if(reader.Getattribute != "") // I made that up on the spot, I'm not sure if that would really work { Console.WriteLine("<{0}...

XMLWriter vs XMLDictionaryWriter

What's the difference between XMLWriter and XMLDictionaryWriter? In which cases is each one generally used? ...

How to create a XML with a Specific Encoding using XSLT and XMLWRITER

I am trying to apply a XSL style sheet on a source xml and write the output to a target xml file. The xsl removes the xml comments present inside the source xml. The target xml file has UTF-16 encoding in the header. But still i want the output xml to be utf-8 encoding. The code i used is XmlWriterSettings xwrSettings = ...

Syntax error in xml-writer

I have seen an example of an XML-writer in another quistion: <?php $writer = new XMLWriter(); $writer->openURI('php://output'); $writer->startDocument('1.0','UTF-8'); $writer->setIndent(4); $writer->startElement('items'); $writer->startElement("main"); ...

[iPhone] How to write XML files?

Hi. I want to write a not so complicated but large file within my app and be able to send it by mail (using MFMailComposeViewController) Since NSXMLElement and related classes are not ported to iPhone SDK what options do I have for creating XML documents? Thanks in advance. ...

C# Adding data to xml file

I'm building an Parts app in order to learn C# and WPF. I trying having trouble adding new parts using XmlWriter. I can create the xml file, but can not figure how to add additional parts. Should I be using something else like XmlDocument? Here is my code behind: private void btnSave_Click(object sender, RoutedEventArgs e) { ...

Writing to XML in a Pocket PC

Hi again. I have a list of songs which I want to output to an external XML file using a smart device (pocket pc). String path = GetAppDir(); string filePath = path + @"\output\songs.xml"; XmlWriter xmlOut = XmlWriter.Create(filePath, settings); xmlOut.WriteStartDocument(); xmlOut.WriteStartElement("Songs"); foreach (Song songTmp in...

Serialization of object to xml and string without \r\n special characters.

Hi, I want to serialize my object to xml and then to a string. public class MyObject { [XmlElement] public string Name [XmlElement] public string Location; } I want to obtain a single line string which will lok like this: <MyObject><Name>Vladimir</Name><Location>Moskov</Location></MyObject> I am using such cod...

How to write out an EntityReference (e.g. &nbsp;) to an XmlWriter, read by XmlNodeReader?

Background I'm reading and writing an XML document using reader and writer, with filtering logic in between the read and write operations to determine which parts read should be written back out (effectively it strips some tags out) ... My choice of implementation currently is the following using: XmlNodeReader, XmlWriter and XmlNodeTyp...