Advise, Guidance and Pointers with XML

Dear Ethernet of Unquestionable Knowledge,

        Re: Advise, Guidance and Pointers with XML

Oh omnipotent one(s) please help me ... I'm reasonably new to all the
XML stuff and although clear on the basic concepts of XML, however I'm
experiencing some difficulties in understanding how to implement and
utilise these concepts within a real world solution.

(1) Serialization

(a)

When I serialize my class object(s) the returning XML contains a random
character(s) at the beginning of the document. Do you have any idea why
this may be occurring? I.e.

?Encoding.UTF8.GetChars(memoryStream.GetBuffer())
{Length=694}
    [0]: 65279 ''
    [1]: 60 '<'
    [2]: 63 '?'
    [3]: 120 'x'
    [4]: 109 'm'
    [5]: 108 'l'
....

I'm using the similar code found in this example ...

[http://www.dotnetjohn.com/articles.aspx?articleid=173]

.... so what's with this random UTF8 character [65279]? (Note 65279
equates to three question-marks in ASCII, I assume this is because
there is no corresponding character in the ASCII set and this character
takes up the space of three normal ASCII characters, but what is it?)

(b)

When I serialize my classes object the returning XML contains \"
[backslash + quotation-mark] rather than a simple quotation mark.
What's with that ... copying and pasting this into a blank .xml file
results in error when opening the document in Internet Explorer. It
just don't like it!

(c)

I was also looking into different methodologies of Serialization for my
class and resulted in an XML document containing \r\n which I'm
assuming has something to do with the formatting of the document. Do
you know what these are, what they're used for?

(2) Passing XML to SQLServer Stored Procedures

(a)
I can see that debugging the stored procedure on the database is going
to be a pain. I managed to clean the XML document created by the code
to replace \" with a single quote mark, but this is useless to me if
I want to debug a stored procedure that takes in XML, as I can't
write an Execute statement when the input variable contains several
single quotes? How do you go about debugging stored procedure that
takes in XML data?

(b)
I guess and overview of how to pass data between a c#.net application
to a SQL database system would be of great help. I'm recently new to
c# as well (coming from a VB background) which really doesn't help.
If you can help with any of the above then please drop me a line and
pass on that knowledge. The learning curse is kind of steep!

Regards,

Tim

P.S. I bow down to your otherwise superior knowledge and intellect!

0
11/30/2006 5:47:39 PM
dotnet.xml 7266 articles. 0 followers. Follow

1 Replies
724 Views

Similar Articles

[PageSpeed] 35

Caspian wrote:

> When I serialize my class object(s) the returning XML contains a random
> character(s) at the beginning of the document. Do you have any idea why
> this may be occurring? I.e.
> 
> ?Encoding.UTF8.GetChars(memoryStream.GetBuffer())
> {Length=694}
>     [0]: 65279 ''

Could be a byte order mark (BOM), see
   <http://en.wikipedia.org/wiki/Byte_Order_Mark>


> When I serialize my classes object the returning XML contains \"
> [backslash + quotation-mark] rather than a simple quotation mark.
> What's with that ... copying and pasting this into a blank .xml file
> results in error when opening the document in Internet Explorer. It
> just don't like it!

Usually when people report this they are looking at strings in an IDE or 
debuggger which tends to escape such characters. When the XML is saved 
directly to a stream or file then the character is not escaped and the 
XML is well-formed.




-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1777)
11/30/2006 6:39:50 PM
Reply:

Similar Artilces:

XML corruption when sent as email body...
Hi, Not sure if this is entirely an XML issue - but if I send an XML document in the message body of an email it gets mangled as follows... <dsOrderSummary= xmlns=3D"http://www=2Etempuri=2Eorg/dsOrderSummary=2Exsd"> The line of XML should actually read... <dsOrderSummary xmlns="http://www.tempuri.org/dsOrderSummary.xsd"> Equals signs are inserted, and periods end up as 2E. Any ideas? Rich "Richard Moore" <nospam@nowhere.com> wrote in message news:1105642310.6c2dd2d87216cae3dfb73b88155fefc5@teranews... > Not sure if this is entirely ...

hi xml
...

Dropdown menu using xml file
Can anyone please help me. I was looking at the article "http://www.eggheadcafe.com/articles/20030603.asp". I am new to .net and know nothing in c#. I want to write a menu in asp.net. Can anyone please help me in converting this c# code to vb.net. I tried, but it is not giving the output. Here is the c# code using System using System.Collections using System.ComponentModel using System.Data using System.Drawing using System.Web using System.Web.SessionState using System.Web.UI using System.Web.UI.WebControls using System.Web.UI.HtmlControls using System.Xml; using System.Xml.Xsl; us...

Export to XML exports single row only
What I did: On XML source panel of Excel 2007 added XML map, mapped to columns using ranges (i. e. A1:A1825), selected “Export” from “Developer” tab in the ribbon. Result: Output XML file contains only one record (first row from the worksheet) I’ve done this numerous times in Excel 2003 with no problem. What happens?? Please help! Thanks, Eugene ...

XSLT: Creating anchors from outer XML files
Hi, I'm trying to put the links (href attribute of the <a> element) out of my XSLT files, in a XML file, and read it from the stylesheet. I suppose that I have to use the document() function to link to the XML file containing the URLs, but I don't know how to do it. I've tried something like this: This is XML file containing the URLs (link.xml): <?xml version="1.0" encoding="utf-8" ?> <LINKS> <L1> /SomePage.aspx </L1> </LINKS> And this is the code from the stylesheet: <a href="{document('link.xml')/L...

econnect using com/xml
How should I use econnect using com object or by using xml services - instead of using MSMQ. DO any one have worked on it? Thanks. I have not used the xml services. Is that something new for econnect 9.0. I have used the COM object and the .NET assembly for econnect 8.0. If you are developing in .NET, you have to use the .NET assembly, the COM object does not work. The COM is good for VB6. Peter "ACE_Shankar" wrote: > How should I use econnect using com object or by using xml services - instead > of using MSMQ. DO any one have worked on it? > > Thanks. > ...

XML Schema Validation + Deserialization
I would like to perform a 2-pass XML reading from a stream. Once using the Validating reader, just to confirm the validity against the schema, and next time to do a reading to extract the data. Actually, second time I do a deserialization, the data from XML is fed directly to an object. The problem I am experiencing is the error at the second reading attempt, and error description implies that reader is winded to the end of the XML and tries to read from there. Let me introduce you to the code first (VB.NET): (>>> the source XML is in InStream <<<) ' xmlReader - re...

Pointer to Multi-Dim Array
I can't believe I can't figure this out! #define MAX_COL 200 #define MAX_ROW 300 int MyArray[MAX_COL][MAX_ROW]; MyArrayFunction(VarArray[][MAX_ROW]); Main() { // Fill Array.... ..... // Call array Function MyArrayFunction(MyArray); .... } MyArrayFunction(VarArray[][MAX_ROW]) { // Do things to array .... } The above sample works fine. The problem is in "Main", I need to make a pointer, to the multi-dim array. If I write: int ArrayPointer [][MAX_ROW]; The compiler returns an error: "can not convert 'int [][300]' to 'int[][300]'. How ...

MSExchange.UceContentFilter.xml
ok whats the score with having to manually copy this from the old .dll+.dat folder to the new one and stop and start smtp when the IMF does an auto update. is this going to be automated in the future? surely it would make sense to just keep the MSExchange.UceContentFilter.xml in the root MSCFV2. ...

Export contacts in XML
I would like to export my contacts from Outlook express in a xml's file. I know if possibile to export in CSV than convert with excel to xml, but what I would like do it with a single step. I've looked for 3D part sw, but I haven't results, TIA -- Max Art2009;109587 Wrote: > I would like to export my contacts from Outlook express in a xml's > file. > I know if possibile to export in CSV than convert with excel to xml, > but > what I would like do it with a single step. > I've looked for 3D part sw, but I haven't results, Thi...

Excel XML Time format & arithmetic
Hi all, I have an Excel Xml file and I want to perform a Sum operation with time format cells. If I set [h]:mm format to the cells ¡, I can see the next right values: 8:25 8:30 25:25 42:20 (SUM) When I save the file as Excel XML 2003, I have this: <Styles> <Style ss:ID="s64"> <NumberFormat ss:Format="[h]:mm"/> </Style> </Styles> <Row ss:AutoFitHeight="0"> <Cell ss:Index="2" ss:StyleID="s64"><Data ss:Type="DateTime">1899-12-31T08:25:00.000</Data></Ce...

Example needed: simple XML file and parsing
A dropdownlist in my ASP.NET webform needs to be populated from values taken from an XML file. Can someone provide a (simple) sample XML file and a parsing routine using VB.NET? The values could be something like: Fruits Vegetables Meats Dairy Thanks in advance! How about something like this: Dim dstDataSet As New DataSet dstDataSet.ReadXml(Server.MapPath(".") & "\Items.xml") With DropDownList1 .DataSource = dstDataSet .DataValueField = "id" .DataTextField = "name" .DataBind() End With Then crea...

xml schema design #2
I have an xml schema that I am working on. I wanted to know if it was a normal thing to do something like this: 1. Have a ZipCode simple type that has to be 5 characters long. 2. Have a StateCode simple type that has to be 2 characters long. 3. Have an Address complex type that has: - Street (string) - City (sgring) - State (StateCode) [noted in item 2 above] - ZipCode (ZipCode) [noted in item 1 above] 4. Have a Venue complex type that has the following: - Name (string) - Address (Address) [noted in item 3 above] - PhoneNumber (string) 5. Have an element that can contain only 1 instance of t...

XML and & character as data
Hello, I have a XML file using Iso 8859-1 encoding. Every time when I try to put & character as Tag's value XMLDocument Reader throws Exception. How should I code & character as an ordinary data character in XML file? Cheers! BenI wrote: > How should I code & character as an ordinary data character > in XML file? Escaped as &amp; (& a m p ; for web interface readers). -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/ * BenI wrote: > Hello, > > I have a XML file using Iso 8859-1 encoding. > Every time when I try to put & ...

Minimum requirements for XML file for visio org chart
I am trying to develop the minimum requirements needed in a XML file for import into a Visio org chart (Boxes, with a few lines of text each, and connectors between them). Does any one have an example? ...

Adding data (autoincrement) into a xml file with the help of a dataset
Hi, I have a strange problem with my xml file. In the schema of this xml file I have set one column to autoincrement. When I enter the data in my xml file directly, the autoincrement-column gets its correct values. Now I want to add new data with the help of a dataset. I use the following lines of code: Dim ds_functions As New DataSet ds_functions.ReadXml("Test.xml") Dim drCurrent As DataRow drCurrent = ds_functions.Tables(0).NewRow drCurrent(1) = Me.txt_bla.Text ds_functions.Tables(0).Rows.Add(drCurrent) Dim sw As System.IO.StreamWriter = New System.IO.StreamWriter("Test.x...

.NET XML based AutoUpdater
Some of you might be interested in this open source AutoUpdater for ..NET "Sharp AutoUpdater provides an auto-update feature for .NET applications. Using XML configuration files, Sharp AutoUpdater component detects if there is a new version of the software, downloads, unzips, and installs the new files." Link: http://csautoupdater.sourceforge.net/ ...

User entered data in XML
I'm writing data the user enters out to an XML file (using DataSet.WriteXML; DataSet is a typed DataSet created from an XML Schema). The problem I'm having is the user can (and needs to) enter characters like &, < and >. Is there some .NET function (maybe something in System.Xml) that will take a string and format it for output to an xml file (such as change all &'s to &amp;, etc.)? I'd hate to have to do String.Replace("&", "&amp;").Replace(...).Replace(...) all the fields manually, but if that's my only alternative... Ne...

Import Excel XML into Dataset
Hi I'm trying to import some Excel XML into a dataset. If I use the below code on some standard XML it works fine. If I use it on XML created from Excel I will get (will xmlread): Specified cast is not valid. What do I need to do to my code so it can read Excel XML? Many thanks Alex -----> Dim thisdataset As New DataSet Dim xmlfilename As String = "filename.xml" Dim fsReadXml As New System.IO.FileStream _ (xmlfilename, System.IO.FileMode.Open) Dim myXmlReader As New System.Xml.XmlTextReader(fsReadXml) thisdataset.ReadXml(myXmlReader) myXmlReader.Close() ...

Checkboxlist with XML
Hello, I have a novice question: How do you populate a checkboxlist with XML data? TIA Actually, that depends on a lot. Has it to be high performant? Do you have to search in the xml file? Do you need to do some transformation of the xml file? .... You can find a lot of documentation about this on the internet. For example, a nice document of the different way's you can use, can you find at http://support.softartisans.com/kbview.aspx?ID=674 It describes the most commenly used way's to access the data in xml files, and also mentions when to use which way. If I had to choos...

Root element in XML designer and .xsd'd
Forgive a newbie question. I'm learning the .NET XML environment. In the walkthrough on using XML designer to create an xsd, there is no discussion of the root element of the target xml document. I realize that the namespace specifying the xsd is an attribute of the root element of an xml document conforming to the xsd, so is logically outside the xsd. I built a simple schema, then added an XML document, added a root element to the document, and specified an xmlns attribute to link in the schema. The correct schema is shown in the document property, and intellisense shows the eleme...

CrmTranslations.xml
Hello, I've got an attribute (new_telephone), the attributename is Telephone (private), I've changed the display name in the Form to just "Telephone", and thats exactly what i want, the two names have to be different, when i open a company now, it shows me "Telephone" in the Form, but when i go to "Advanced Find" it shows me "Telephone (private)". Thats how I need it. The problem I've got now is that when i want to translate it into a different language, for example german, it just does not work. I've got 2 different entries in th...

how to use pointers to CWnd in threads
When pointers of CWnd of its subclasses are transferred over thread boundaries, their AsserValid method will fail. The result is I can not transfer a pointer to a CWnd class or its subclass to other threads. Now I can only used HWND, but that is inconvenient. How can I transfer a pointer to CWnd to other threads and keep it usable? Hallo fefe! > When pointers of CWnd of its subclasses are transferred over thread > boundaries, their AsserValid method will fail. The result is I can not > transfer a pointer to a CWnd class or its subclass to other threads. Now I > can only...

Query/Filter XML to produce new document
Hi I'm looking to take an existing XML document, query for certain nodes, and 'recreate' the document with just the relevant nodes. I'm currently using XPath - I have established the pattern that returns the required child nodes from the document, but am struggling to find a good statergy for recreating the file Here is an excert of my XML file <resource_data><planets><planet name="Planet1"><resources><resource><name>Resource1</name><ut>463</ut></resource><resource><name>Resource2</name>&l...

Reading an XML file with " and ' as attribute value quotes
Hello, I am currently working on a build solution for multiple c#/vb projects and I'm nearly done. There is one single problem remaining: In case one of the project settings contains a " (double quote ;-), the attribute's value within the project file will automatically be surrounded by ' (single quotes). So far so bad - A XmlDocument.Load() call will now fail with a syntax error exception because there are two quote characters used within the Xml. How would it be possible to read such a miss formed XML-file? Is it possible to write such a smart XmlReader or is there a much...