📄 xmldlg.cpp
字号:
// xmlDlg.cpp : implementation file
//
#include "stdafx.h"
#include "xml.h"
#include "xmlDlg.h"
#include "CEXML.h"
#include <msxml.h>
#include "MYXML.h"
#include <comdef.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CXmlDlg dialog
CXmlDlg::CXmlDlg(CWnd* pParent /*=NULL*/)
: CDialog(CXmlDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CXmlDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CXmlDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CXmlDlg)
DDX_Control(pDX, IDC_LIST1, m_list);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CXmlDlg, CDialog)
//{{AFX_MSG_MAP(CXmlDlg)
ON_BN_CLICKED(IDC_BTNLOAD, OnBtnload)
ON_BN_CLICKED(IDC_BTNADD, OnBtnadd)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CXmlDlg message handlers
BOOL CXmlDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
CenterWindow(GetDesktopWindow()); // center to the hpc screen
// TODO: Add extra initialization here
//load xml
iLoad =myxml.LoadXML(L"\\Storage Card\\SType.xml");
//init list
m_list.InsertColumn(0,L"业务编号",LVCFMT_LEFT,80);
m_list.InsertColumn(1,L"业务名称",LVCFMT_LEFT,80);
m_list.InsertColumn(2,L"开始时间",LVCFMT_LEFT,80);
m_list.InsertColumn(3,L"停止时间",LVCFMT_LEFT,80);
return TRUE; // return TRUE unless you set the focus to a control
}
void CXmlDlg::OnBtnload()
{
// TODO: Add your control notification handler code here
if(iLoad)
{
IXMLDOMNodeList *NodeList = NULL;
IXMLDOMNode *iNode = NULL;
NodeList = myxml.FindNodeList(L"/SType/node");
long count = 0;
NodeList->get_length(&count);
for(int i=0;i<count;i++)
{
NodeList->get_item(i,&iNode);
EmulatNodeText(iNode);
}
}
}
BOOL CXmlDlg::ListNode(IXMLDOMElement *iNode)
{
return false;
}
CString CXmlDlg::EmulatNodeText(IXMLDOMNode *pNode)
{
IXMLDOMNode *pchild = NULL;
pNode->get_firstChild(&pchild);
BSTR bstr;
pchild->get_text(&bstr);
CString szText,NodeText;
szText.Empty();
szText = CString(bstr);
do
{
IXMLDOMNode *Sibling = NULL;
pchild->get_nextSibling(&Sibling);
pchild = Sibling;
BSTR bstr;
pchild->get_text(&bstr);
CString szText;
szText.Empty();
szText = CString(bstr);
}while( pchild!= NULL);
return "";
}
void CXmlDlg::OnBtnadd()
{
// TODO: Add your control notification handler code here
if(iLoad)
{
if(myxml.AddNode(L"/SType"))
{
if(myxml.SaveXML(L"\\Storage Card\\SType3.xml"))
MessageBox(L"Success");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -