|
I assumed that but just wanted to make sure. I never came across a property or similar that lets you adjust the usage of a BOM header and after a quick glance at MSDN I also did not find one. In your original post you said that the BOM header is only sometimes put in front of the XML markup. Are you able to narrow this down the some concrete conditions under which this happens?
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
The input XML files are configuration files from hardware units, but the format differs slightly depending on the version of hardware. I have only just come up against this BOM header insertion, but it seems like it could be a certain age (not sure whether it's newer or older at the moment) hardware gives an XML file which ends up being edited in my application and the BOM header added.
The file does have the UTF-8 ?xml tag at the top which I am assuming is causing the BOM header to be added by the .NET parser, but that's the bit that causes the hardware unit to not accept the new config file.
|
|
|
|
|
Ok, in case you're using Framework 2.0, there may be a way to get around your problem. The XmlDocument.Save method has an overload that takes an XmlWriter object. The XmlWriter class has a overload of the static Create method that takes a filename and a XmlWriterSettings instance (class is new in 2.0). This class exposes a Encoding property that allows to specify the text encoding to be used. Finally there is the UTF8Encoding class that has a constructor taking a boolean that specifies whether the byte order marked is provided or not.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Fantastic, that sounds like what I need. I'm using 2.0, so I'll take a look at writing out in that way.
Thanks a lot
|
|
|
|
|
That seemed to do the trick, but using this method the XML file is saved without line breaks at all. I've tried changing the various options of XmlWriterSettings but can't work out how to make sure the file is formatted properly. When I was just using xmlDoc.Save it was laying the file out correctly but adding the BOM, now it's saving the file in the right encoding (I chose ASCII rather than UTF-8 as that's what the files I'm editing are in) but without the formatting (which again is causing errors with the hardware units).
|
|
|
|
|
I'm sorry to hear it does not work properly. Since I have no pratical experience with customizing the writing of XMl files (output generated by XmlDocument.Save was always sufficient for my needs), I cannot really help you here. The best thing I can suggest is playing around with the properties of the XmlWriterSettings class regarding new lines (obviously you already done this), check whether this only happens if you use the ASCIIEncoding class or also with other encodings and maybe use the same XmlWriterSettings for reading too.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
I finally worked it out... the XmlWriterSettings.Indent setting not only indents, but also adds the line breaks.
|
|
|
|
|
Duncan Sample wrote: I finally worked it out...
Congratulation
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi..
I need to create aspx page dynamically using xml and xslt? Could anyone please help me in creating an Aspx page using xml and xslt.
Thanks & Regards,
Venkat
|
|
|
|
|
What is it exactly that you need help with?
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
I need to create new aspx page with the help of xml and xslt? The aspx page has to be created hrough xml and xslt
Thanks & Regards,
Venkat
|
|
|
|
|
You already said that. Simply repeating your question does not bring you any closer to getting a useful answer.
So I rephrase the question a bit. What should be contained in the XML file and what should the transformation with XSLT do? Did you already read something about XSLT? If not the following site would be a good starting point http://www.w3schools.com/xsl/.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
What are you trying to create from xml file? Final HTML markup, or "aspx page" with user controls like <asp:TextBox> etc?
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
|
|
|
|
|
I want to have an array of finite numbers/strings in the xml and validate it using the XSD file, can this be done
i know i could concatenate the array pass as comma seperated string or something but is there a better more standard way
thanks for your help
If you think you can than you can, if you think you can't you are right.
|
|
|
|
|
I'd suggest using a structure like this:
<complexType name="numbersArray">
<sequence>
<element name="item" type="xsd:int" minOccurs="0" maxOccurs="unbounded" />
</sequence>
</complexType>
A conforming XML file would look like this:
<numbersArray>
<item>1</item>
<item>5</item>
</numbersArray>
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cookwww.troschuetz.de
|
|
|
|
|
Excellent
Haven't tried it yet but thanks
Is there anyway to tweak this to use enums as well
[edit]forgot to vote 5! [/edit]
|
|
|
|
|
Monty2 wrote: Is there anyway to tweak this to use enums as well
Do you mean like that?
<simpleType name="color">
<restriction base="xsd:string">
<enumeration value="red" />
<enumeration value="green" />
</restriction>
</simpleType>
<complexType name="colorArray">
<sequence>
<element name="item" type="color" minOccurs="0" maxOccurs="unbounded" />
</sequence>
</complexType>
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cookwww.troschuetz.de
|
|
|
|
|
Can you please write the corresponding XML as well thankyou so much for your precious time
[edit]sorry got it[/edit]
If you think you can than you can, if you think you can't you are right.
|
|
|
|
|
I need to create XML document from schema without using any tool (dynamically)
|
|
|
|
|
I want to create an light weight XML database, but I don't find anything which could interest me.
It is to make a very small DB, in XML format (so it could be modified with any text editor). I want to completely integrates database API in my executable (I don't want to use software like MySQL or PostgreSQL, because it must be on any computer with no installation required). So my executable must integrates database API and store data into XML file format.
I've an idea about using SQLite and any XML parser like Pugxml but I would like to find something like SQLite with storing data directly in XML.
does anyone knows something about doing this ?
I work on Visual C++ 6.0 Sp6 (MFC/ATL).
thanks for all
Le Sourcier
My Foo website
|
|
|
|
|
How the XML declaration differs for Valid and Well Formed XMLs. And how can we select give the values for "Version" and "Encoding" attributes in an XML file. Thank you.
Regards,
S/W Engineer
Akebono Soft Technologies
aleem_abdul@akebonosoft.com.
|
|
|
|
|
indian143 wrote: How the XML declaration differs for Valid and Well Formed XMLs.
It does not differ.
indian143 wrote: And how can we select give the values for "Version" and "Encoding" attributes in an XML file.
What exactly does that mean? Do you want to retrieve the concrete values values of a specific XML file?
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
What is xsd and xslt. Whats the difference between these two. What will be the first line in every valid and well-formed xml files.
How these xsd and xsld are usefull to define a valid and well formed xml file. Thank you in advance.
Regards,
S/W Engineer
Akebono Soft Technologies
aleem_abdul@akebonosoft.com.
|
|
|
|
|
indian143 wrote: What is xsd and xslt. Whats the difference between these two.
http://www.w3schools.com/[^]
indian143 wrote: What will be the first line in every valid and well-formed xml files.
The XML declaration
indian143 wrote: How these xsd and xsld are usefull to define a valid and well formed xml file.
XSLT has nothing to do with validity of XML files.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi all,
Can anybody please tell me the difference between Well formed and Valid XML. Thank you.
And please give me a link for knowing about the XML and contents of Valid and Well formed XML's and how to create them. Thank you.
Regards,
S/W Engineer
Akebono Soft Technologies
aleem_abdul@akebonosoft.com.
|
|
|
|