Click here to Skip to main content
15,892,643 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to simulate click button on win32 form ? Pin
#realJSOP18-Jan-10 1:00
mve#realJSOP18-Jan-10 1:00 
GeneralRe: How to simulate click button on win32 form ? Pin
Yanshof18-Jan-10 1:09
Yanshof18-Jan-10 1:09 
GeneralRe: How to simulate click button on win32 form ? Pin
Wes Aday18-Jan-10 4:15
professionalWes Aday18-Jan-10 4:15 
GeneralRe: How to simulate click button on win32 form ? Pin
#realJSOP18-Jan-10 10:24
mve#realJSOP18-Jan-10 10:24 
GeneralRe: How to simulate click button on win32 form ? Pin
Yanshof18-Jan-10 17:20
Yanshof18-Jan-10 17:20 
GeneralRe: How to simulate click button on win32 form ? Pin
#realJSOP18-Jan-10 23:26
mve#realJSOP18-Jan-10 23:26 
AnswerRe: How to simulate click button on win32 form ? Pin
Rick Shaub18-Jan-10 3:31
Rick Shaub18-Jan-10 3:31 
Question"Unescape" ISO string Pin
Keith Barrow18-Jan-10 0:48
professionalKeith Barrow18-Jan-10 0:48 
Hi,

I have a large (0.5GB) XML file. I'm effectively copying it at the moment (with a view to changing certain values in the xml for testing). I'm using the XmlTextReader and Writer to perform this task.

Here is my code:

static void ProcessNode
{
    //Other node type processed [correctly] before and after this method....
    if (reader.NodeType == XmlNodeType.Text)
    {
        string source = SecurityElement.Escape(reader.Value);
        writer.WriteRaw(source);
        return; 
    }     
}

static void ProcessFile(XmlTextReader reader)
{
    reader.Read(); // Read the first element to get encoding
    using (XmlTextWriter writer = new XmlTextWriter(destinationPath, reader.Encoding))
    {
        Process(reader, writer); //Process the first element
        while (reader.Read()) //Now process all remaining elements
        {
            ProcessNode(reader, writer);
        }
    }
}

static void Main(string[] args)
{
    using (XmlTextReader myReader = new XmlTextReader(sourcePath))
    {
        ProcessFile(myReader);
    }
}


I'm having problems with escape sequences. The line string source = SecurityElement.Escape(reader.Value); Unescapes "'" to ' and "<" to &lt; etc, which is desired. My problem is this: I have accented, non-english characters that have the escape sequences (e.g. Ú should be written as &#xda;). I cannot figure out how to Unescape such caracters.

As a side note, the line writer.WriteRaw(source); was writer.WriteString(source); both with and without the SecurityElement.Escape writes even the apostrophe unescaped, as well as the non-English caracters I'm still having problems with. This seems to be in direct opposition to http://msdn.microsoft.com/en-us/library/system.xml.xmltextwriter.writestring.aspx[^] as far as I can tell.

If anyone can spot where I've gone wrong, it would be appreciated, this should have been a 1/2 day task for me and has taken a day so far....

CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks

AnswerRe: "Unescape" ISO string Pin
PIEBALDconsult18-Jan-10 3:22
mvePIEBALDconsult18-Jan-10 3:22 
GeneralRe: "Unescape" ISO string Pin
Keith Barrow18-Jan-10 3:35
professionalKeith Barrow18-Jan-10 3:35 
GeneralRe: "Unescape" ISO string Pin
mdirkes18-Jan-10 3:52
mdirkes18-Jan-10 3:52 
GeneralRe: "Unescape" ISO string Pin
Keith Barrow18-Jan-10 4:12
professionalKeith Barrow18-Jan-10 4:12 
GeneralRe: "Unescape" ISO string Pin
PIEBALDconsult18-Jan-10 12:40
mvePIEBALDconsult18-Jan-10 12:40 
AnswerAnswer: But I feel dirty, and not in a good way..... Pin
Keith Barrow18-Jan-10 5:27
professionalKeith Barrow18-Jan-10 5:27 
AnswerRe: "Unescape" ISO string Pin
mav.northwind7-May-10 4:51
mav.northwind7-May-10 4:51 
QuestionExecute and exe from WinService in C# [modified] Pin
Sunil G18-Jan-10 0:40
Sunil G18-Jan-10 0:40 
AnswerRe: Execute and exe from WinService in C# Pin
#realJSOP18-Jan-10 1:03
mve#realJSOP18-Jan-10 1:03 
GeneralRe: Execute and exe from WinService in C# Pin
Sunil G18-Jan-10 1:08
Sunil G18-Jan-10 1:08 
GeneralRe: Execute and exe from WinService in C# Pin
#realJSOP18-Jan-10 2:49
mve#realJSOP18-Jan-10 2:49 
GeneralRe: Execute and exe from WinService in C# Pin
Sunil G18-Jan-10 2:53
Sunil G18-Jan-10 2:53 
GeneralRe: Execute and exe from WinService in C# Pin
Md. Marufuzzaman18-Jan-10 3:33
professionalMd. Marufuzzaman18-Jan-10 3:33 
GeneralRe: Execute and exe from WinService in C# Pin
#realJSOP18-Jan-10 3:35
mve#realJSOP18-Jan-10 3:35 
QuestionWriting to Excel without installation of MS Excel Pin
Priya Prk18-Jan-10 0:11
Priya Prk18-Jan-10 0:11 
AnswerRe: Writing to Excel without installation of MS Excel Pin
OriginalGriff18-Jan-10 0:17
mveOriginalGriff18-Jan-10 0:17 
GeneralRe: Writing to Excel without installation of MS Excel Pin
Priya Prk18-Jan-10 1:03
Priya Prk18-Jan-10 1:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.