I use .NET XML technologies quite extensively on my work. One of the things the I like very much is the XSLT engine, more precisely the extensibility of it. However there one little piece which keeps being a source of annoyance. Nothing major or something we can't live with but it is preventing us from producing the beautiful XML we woul...
The PHP documentation can be found here, but I think it's rather lacking. There are no examples of how to use these functions, and few (if any) of the pages have user comments. So where might I be able to find an explanation (and example code) on how to use these functions to write an XML document?
...
I've got a function creating some XmlDocument:
public string CreateOutputXmlString(ICollection<Field> fields)
{
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.Encoding = Encoding.GetEncoding("windows-1250");
StringBuilder builder = new Strin...
There are multiple places in an application which call XmlWriter.Create on the same file, all accessed through the following function. When one calls while another is still writing, I get an IOException. What's the best way to lock or synchronize access?
Here's the function that's being used:
public void SaveToDisk()
{
...
I'm writing a Windows service in C#. I've got an XmlWriter which is contains the output of an XSLT transformation. I need to get the XML into an XMLElement object to pass to a web service. What is the best way to do this?
...
Here's some C# code:
var sb = new StringBuilder();
var w = XmlWriter.Create(sb);
w.WriteStartElement("hello");
w.WriteAttributeString("target", "world ' \" !");
w.WriteEndElement();
w.Flush();
// then look at sb.ToString()
I'm getting a string that looks like:
<?xml version="1.0" encoding="utf-16"?><hello target="world ' " !" /...
I am creating an ASHX that returns XML however it expects a path when I do
XmlWriter writer = XmlWriter.Create(returnXML, settings)
But returnXML is just an empty string right now (guess that won't work), however I need to write the XML to something that I can then send as the response text. I tried XmlDocument but it gave me an erro...
Hi there,
lets begin with the scenario:
I have an ItemsControl inside a UserControl. In this ItemsControl I have a dynamicly created DataTemplate which is created and added in codebehind. As there doesn't seem to be a nice way to create a DataTemplate in codebehind I had to programmatically generate the xaml code for my DataTemplate in...
Here is my code, see the part that says ???WHAT TO DO HERE??? I am not sure where I write this XML to in order to be able to send it in my POST via the objRequest there...
string project_id = context.Request.QueryString["project"];
string person_id = context.Request.QueryString["person"];
string post_date = context.Request.QueryString["...
I have the following code:
MemoryStream ms = new MemoryStream();
XmlWriter w = XmlWriter.Create(ms);
w.WriteStartDocument(true);
w.WriteStartElement("data");
w.WriteElementString("child", "myvalue");
w.WriteEndElement();//data
w.Close();
ms.Close();
string test = UTF8Encoding.UTF8.GetString(ms.ToA...
Hello,
How do I get this output?
<MSRP currency="USD">10.00</MSRP>
writer.WriteElementString("MSRP", Convert.ToString(q.ItemPrice1));
writer.WriteAttributeString("currency", "MSRP", "USD");
this is the error:
Token StartAttribute in state Content would result in an invalid XML document.
...
Hi,
I'm working on an XML webservice (in PHP!), and in order to do things 'right', I want to use XMLWriter instead of just concatinating strings and hoping for the best.
I'm using XML namespaces everywhere using ->startElementNS and ->writeElementNS. The problem, is that every time I use these functions a new namespace declaration is a...
I have a requirement to make an XML file - and the partner is rather sticky about the header. Apparently, the header must be exactly this:
<?xml version="1.0"?>
But whenever I create an XML file I get extraneous properties like this:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
The hacker in me wants to stop using XMLWr...
I'm modifying some .vcrpoj files in .NET but when I save them the formatting changes (which wrecks havoc with my diff tool), the original files look like this:
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
But when I save the changes it lo...
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 a...
I'm working on a cross-platform solution currently. The solution uses XmlMtomReader and XmlMtomWriter from .NET framework 3.0.
Now i need to know if these two classes (and all the nessasary infrastructure around them) are fully supported in Mono project from the porting-it-to-linux point of view. :)
...
I am using an XmlWriter to render HTML. How can I get an XmlWriter to emit a proper tag that looks like this?
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
here is what I have so far
var xml = XmlWriter.Create(HtmlFileName, new XmlWriterSettings { Indent = true, OmitXmlDeclaration = true});
xml.WriteDocType("html...
I'm writing out an XML file using VB.net. When I try to create another element to be written past the first, it errors out saying:
"Token StartElement in state EndRootElement would result in an invalid XML document. Make sure that the ConformanceLevel setting is set to ConformanceLevel.Fragment or ConformanceLevel.Auto if you want to...
Hi, i need to remove the BOM from an XML file that is being created. I have tried using the new UTF8Encoding(false) method but it doesnt work. Here is the code i have:
XmlDocument xmlDoc = new XmlDocument();
XmlTextWriter xmlWriter = new XmlTextWriter(filename, new UTF8Encoding(false));
xmlWriter.Formatting = Formatting....
Hi,
I was advised to use XMLwriter to build HTML documents in order to display them in webbrowser object. Creating doctype and startelements like HTML,BODY is OK..but I am experiencing 2 main problems:
I cannot add tags like <br>. Using WriteString skips < and >.
The output string is one line - I would need something like writeLine. Yo...