XML文件不能使用全角中文件字符?(50分)

  • 主题发起人 主题发起人 ynduanlian
  • 开始时间 开始时间
Y

ynduanlian

Unregistered / Unconfirmed
GUEST, unregistred user!
文件1.xml,输完下面内容后用IE打开,报错:
无法显示 XML 页。
使用 XSL 样式表无法查看 XML 输入。请更正错误然后单击 刷新按钮,或以后重试。
--------------------------------------------------------------------------------

文本内容中发现无效字符。处理资源 'file:///C:/Documents and Settings/Administrator/桌面/1.xml' 时出错。第 12 行,位置: 12

<Item> <Old>
第12行即有“ <Item> <Old>二○○一 </Old> <New>** </New> </Item>”,难道XML文件不支持某些全角中文符号?


<Replace>
<Item> <Old>1997 </Old> <New>** </New> </Item>
<Item> <Old>1998 </Old> <New>** </New> </Item>
<Item> <Old>1999 </Old> <New>** </New> </Item>
<Item> <Old>2000 </Old> <New>** </New> </Item>
<Item> <Old>2001 </Old> <New>** </New> </Item>
<Item> <Old>2002 </Old> <New>** </New> </Item>
<Item> <Old>2003 </Old> <New>** </New> </Item>
<Item> <Old>2004 </Old> <New>** </New> </Item>
<Item> <Old>2005 </Old> <New>** </New> </Item>
<Item> <Old>2006 </Old> <New>** </New> </Item>
<Item> <Old>二○○一 </Old> <New>** </New> </Item>
<Item> <Old>二○○二 </Old> <New>** </New> </Item>
<Item> <Old>二○○三 </Old> <New>** </New> </Item>
<Item> <Old>二○○四 </Old> <New>** </New> </Item>
<Item> <Old>二○○五 </Old> <New>** </New> </Item>
<Item> <Old>二○○六 </Old> <New>** </New> </Item>
<Item> <Old>二00一 </Old> <New>** </New> </Item>
<Item> <Old>二00二 </Old> <New>** </New> </Item>
<Item> <Old>二00三 </Old> <New>** </New> </Item>
<Item> <Old>二00四 </Old> <New>** </New> </Item>
<Item> <Old>二00五 </Old> <New>** </New> </Item>
<Item> <Old>二00六 </Old> <New>** </New> </Item>
</Replace>
 
简体中文要用 GB2312 编码
<?xml version="1.0" encoding="GB2312"?>
 
全部代码:
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ShellAPI;

const
AREFRESH_TRAY_ICON=1002;
WM_TRAYNOTIFY=2309;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure WMTrayNotify(var Msg: TMessage); message WM_TRAYNOTIFY;
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
nid: TNOTIFYICONDATA;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
nid.cbSize:=sizeOf(TNOTIFYICONDATA);
nid.Wnd:=Application.Handle;
nid.uID:=AREFRESH_TRAY_ICON;
nid.uFlags:=NIF_MESSAGE or NIF_ICON or NIF_TIP;
nid.uCallbackMessage:=WM_TRAYNOTIFY;
nid.hicon:=Application.Icon.Handle;
nid.szTip:='Project1';
ShowWindow(Handle,SW_HIDE);
ShowWindow(Application.Handle,SW_HIDE);
Shell_NotifyIcon(NIM_ADD,@nid);

end;

procedure TForm1.WMTrayNotify(var Msg: TMessage);
begin
showMessage('OK');
if (Msg.LParam=WM_LBUTTONDOWN) Then
begin
ShowWindow(Application.Handle,SW_SHOW);
Application.Restore;
SetForegroundWindow(GetLastActivePopup(self.Handle));
Shell_NotifyIcon(NIM_DELETE,@nid);
end;
end;

end.
 
nid.Wnd:=Application.Handle;
改为
nid.Wnd:=Handle;
 
CONST CM_TRAYICON = CM_BASE + 84; //托盘图标返回消息

private
procedure showIcon;
procedure OnIconNotify(var Msg: TMessage);message CM_TRAYICON;
Procedure WMSysCommand(Var message : TMessage) ; Message WM_SYSCOMMAND ;

........

procedure TMainForm.showIcon;
begin
hide;
//建立托盘图标
IconData.cbSize := sizeof(IconData); //IconData变量的字节数
IconData.Wnd := Handle; //主窗口句柄
IconData.uID := 1; //内部标识,可设为任意数
IconData.hIcon :=Application.Handle;
//IconData.hIcon:=application.Icon.Handle;
IconData.szTip := '正在运行-//即时通';//图标的提示信息,即黄色的Hint
IconData.uCallbackMessage := CM_TRAYICON;
IconData.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE; //指明哪些字段有效
//将程序的窗口样式设为TOOL窗口,可避免在任务条上出现
SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
Shell_NotifyIcon(NIM_ADD, @IconData); //向托盘中添加图标
end;

procedure TMainForm.OnIconNotify(var Msg: TMessage);
Var
MPoint:TPoint;
begin
Case Msg.LParam of
WM_LBUTTONDBLCLK:
begin
Visible := True;
Application.Restore;
Application.BringToFront;
Shell_NotifyIcon(NIM_DELETE, @IconData);
end;
WM_RBUTTONDOWN :
begin
GetcursorPos(MPoint);
PopupMenu1.Popup(MPoint.X,MPoint.Y);
end;
end;
end;

procedure TMainForm.WMSysCommand(var message: TMessage);
begin
if (Message.WParam = SC_MINIMIZE) then
begin
showIcon;
end
else
Inherited;
end ;

procedure TMainForm.FormCreate(Sender: TObject);
begin
showIcon;
end;
 
来晚了。。。楼上的正解
 
多人接受答案了。
 
后退
顶部