Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 25th, 2006, 11:25 AM
lazygenius
Guest
 
Posts: n/a
Default XML Serialization

I have a class which I am using XML Serialization with, something like:

public class MyObj
{
[XmlAttributeAttribute(DataType="string", AttributeName="Text")]
public string text;

[XmlAttributeAttribute(DataType="boolean", AttributeName="Allow")]
public bool allow;
}

All works fine until I have a string that contains a backslash in the text
member. For some reason, in this case, the XML Serializaer doesn't output
this member. Can anyone tell me what I need to do to get this to work please?

What I want to do is to be able to specify regular expressions in the program
and save them to a user file.



Many thanks in advance.
  #2  
Old July 25th, 2006, 11:55 AM
dickster
Guest
 
Posts: n/a
Default Re: XML Serialization

I cannot regenerate this error - Got this to work

<?xml version="1.0" encoding="ibm850"?>
<MyObj xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Text="Dick\ster"
Allow="true" />


Dickster

  #3  
Old July 25th, 2006, 01:45 PM
lazygenius
Guest
 
Posts: n/a
Default Re: XML Serialization

Thanks for the reply Dickster. The only difference i've got is that the
encoding is "utf-8" in my XML file- maybe that's something to do with it?
  #4  
Old July 26th, 2006, 12:15 PM
dickster
Guest
 
Posts: n/a
Default Re: XML Serialization

I had been serialising to the Console - which I didn't seem to be able
to set to UTF-8

however when I serialise to a file

------------------------------------------------------------------
Dim tw As New System.Xml.XmlTextWriter( _
New System.IO.FileStream("C:\Dickster.xml", System.IO.FileMode.Create),
_
New System.Text.UTF8Encoding(True))

XmlSerializerObj.Serialize(tw, Obj)
------------------------------------------------------------------

I get the following in the output file C:\Dickster.xml
------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?><MyObj
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Text="Dick\ster"
allow="true" />
------------------------------------------------------------------

Dickster

(PS: I use VB.NET but this should have no relevance to the problem)

 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles