xmlwriter

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

☆樱花仙子☆ 提交于 2019-12-24 16:58:07
问题 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 = new XmlWriterSettings(); **xwrSettings.Encoding = Encoding.UTF8;** XslCompiledTransform xslt = new XslCompiledTransform(); xslt.Load("sample.xsl"); StringBuilder sb = new

How to enable XMLReader in PHP without reconfiguring PHP?

感情迁移 提交于 2019-12-24 14:16:14
问题 My PHP info has this: Configure Command : '--with-libxml-dir=/usr' '--enable-xml' '--disable-xmlreader' '--disable-xmlwriter' i.e. my xmlwriter & xmlreader have not been enabled during installation. libxml libXML support active libXML Compiled Version 2.7.8 libXML Loaded Version 20708 libXML streams enabled from php.net manual for XMLReader Runtime Configuration This extension has no configuration directives defined in php.ini . How do I enable XMLReader? / Do I have have to compile my PHP

Does the order of xmlns elements matter

断了今生、忘了曾经 提交于 2019-12-23 08:47:39
问题 I'm not sure how to search google for this but does the matter of the xmlns elements matter in an XML File? I'm creating a XML file using XMLWriter in ASP.NET(VB) and I'm trying to match an example I was provided. <ns2:SubmitSMReq xmlns:ns4="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns3="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-6-MM7-1-4" xmlns:ns2="http://somesite/schema"> This is what I have in my vb file: writer.WriteStartElement("ns2", "SubmitSMReq", "http:

What is the best way to create XML files in Java?

回眸只為那壹抹淺笑 提交于 2019-12-22 18:36:26
问题 We are presently using dom4j to create XML files. However, I'm guessing there's something better now. If we are Java 1.6 or later, what is the best (fastest when running, simple to use) class(es) to use when writing out an XML file. I do not need to build a DOM and then write the entire DOM. I just need something that will write out the elements/attributes as I pass them to the class. thanks - dave 回答1: If you just want to write an XML document having exact control over the creating of

Serialize and Deserialize XML using dot.net c#

≡放荡痞女 提交于 2019-12-19 11:47:26
问题 I have spent the last few hours putting togeather the following code after reading much that seems out of date or that does'nt quite seem to work. If its any help to anybody here is the final working code. Free free to comment if it can be improved :-) public class SerializationHelper<T> { #region static string SerializeObject( T obj, Encoding encoding ) /// <summary> /// Serialize an [object] to an Xml String. /// </summary> /// <typeparam name="T">Object Type to Serialize</typeparam> ///

Encoding issues with XMLWriter (PHP)

不羁岁月 提交于 2019-12-19 10:36:14
问题 Take this simple PHP code: $xmlWriter = new XMLWriter(); $xmlWriter->openURI('php://output'); $xmlWriter->startDocument('1.0', 'utf-8'); $xmlWriter->writeElement('test', $data); $xmlWriter->endDocument(); $xmlWriter->flush(); The XMLWriter class has a nice feature: it will convert any data you give to it to the output encoding. For example here it will convert $data to UTF-8 because I passed 'utf-8' in the startDocument function. The problem is that in my case the content of $data comes from

How do I set the Settings property in XmlTextWriter, so that I can write each XML attribute on its own line?

自闭症网瘾萝莉.ら 提交于 2019-12-19 05:07:45
问题 I have this bit of code, which serializes an object to a file. I'm trying to get each XML attribute to output on a separate line. The code looks like this: public static void ToXMLFile(Object obj, string filePath) { XmlSerializer serializer = new XmlSerializer(obj.GetType()); XmlWriterSettings settings = new XmlWriterSettings(); settings.NewLineOnAttributes = true; XmlTextWriter writer = new XmlTextWriter(filePath, Encoding.UTF8); writer.Settings = settings; // Fails here. Property is read

XMLWriter vs XMLDictionaryWriter

£可爱£侵袭症+ 提交于 2019-12-18 19:08:13
问题 What's the difference between XMLWriter and XMLDictionaryWriter ? In which cases is each one generally used? 回答1: XmlWriter is an abstract class of which XmlDictionaryWriter is one of the classes that inherits from it and is itself an abstract class. I am taking a stab in the dark that you want to use it with the DataContractSerializer or with de/serialization in general. The XmlDictionaryWriter is the base class used by WCF to do its de/serialization. From that I would deduce that there must

How to create an XML file from a XmlReader?

不打扰是莪最后的温柔 提交于 2019-12-17 20:19:27
问题 How do you write an XML file from an System.Xml.XmlReader? I thought this would be a simple question but whenever I search I seem to be ending up with reading the file to a reader or writing node by node. The XmlReader object conveys xml that was stored in a database and just needs to come out of the database to a file. Is there any easy way to do this? SqlCommand dataCmd = new SqlCommand(sqlText, Conn); System.Xml.XmlReader dataReader = null; dataCmd.CommandTimeout = 60000; Conn.Open();

How to create a XmlDocument using XmlWriter in .NET?

萝らか妹 提交于 2019-12-17 17:38:59
问题 Many .NET functions use XmlWriter to output/generate xml. Outputting to a file/string/memory is a very operation: XmlWriter xw = XmlWriter.Create(PutYourStreamFileWriterEtcHere); xw.WriteStartElement("root"); ... Sometimes , you need to manipulate the resulting Xml and would therefore like to load it into a XmlDocument or might need an XmlDocument for some other reason but you must generate the XML using an XmlWriter. For example, if you call a function in a 3rd party library that outputs to