TNB Library
TnbXml.h
[詳解]
1#pragma once
18#include "TnbStr.h"
19#ifndef _TnbDOXYGEN //Document作成用シンボル
20 #ifndef _TnbXML_MsXml6_ENABLE
21 #import <msxml.dll> rename("value", "Value")
22 #else
23 #include "TnbDynamicFunc.h"
24 #import "msxml6.dll" rename("value", "Value")
25 #define MSXML MSXML2
26 #endif
27#endif
28
29#if ! defined(__MSVCPP6__) && ! defined(_UNICODE)
30 #pragma comment(lib,"comsuppw.lib")
31 #pragma comment(lib,"comsuppwd.lib")
32#endif
33
34
35
36//TNB Library
37namespace TNB
38{
39
40
41
52typedef MSXML::IXMLDOMNodePtr CXmlNodePtr;
53
54
55
76{
77public:
78
81 {
85 };
86
87private:
88
89 MSXML::IXMLDOMNodeListPtr m_pNodes;
90 CXmlNodePtr m_pParent;
91 MSXML::IXMLDOMDocumentPtr m_pDoc;
92
94 CXmlNodePtr m_MakeNewNode(ENodeType type, LPCTSTR text)
95 {
96 if ( m_pDoc == NULL )
97 {
98 m_pDoc = m_pParent->GetownerDocument();
99 }
100 CXmlNodePtr n = NULL;
101 _bstr_t str = text;
102 switch ( type )
103 {
104 case ELEMENT:
105 n = m_pDoc->createElement(str);
106 break;
107 case TEXT:
108 n = m_pDoc->createTextNode(str);
109 break;
110 case COMMENT:
111 default:
112 n = m_pDoc->createComment(str);
113 break;
114 }
115 return n;
116 }
117
118public:
119
126 CXmlNodeList(MSXML::IXMLDOMNodeListPtr na, CXmlNodePtr pp, MSXML::IXMLDOMDocumentPtr dc = NULL)
127 : m_pNodes(na), m_pParent(pp), m_pDoc(dc)
128 {
129 }
130
137 bool IsValid(void) const
138 {
139 return m_pNodes != NULL;
140 }
141
148 MSXML::IXMLDOMNodeListPtr operator->(void)
149 {
150 return m_pNodes;
151 }
152
158 size_t GetLength(void) const
159 {
160 return m_pNodes->Getlength();
161 }
162
169 CXmlNodePtr GetNode(INDEX index) const
170 {
171 return m_pNodes->Getitem(static_cast<long>(index));
172 }
173
192 MSXML::DOMNodeType GetNodeType(INDEX index) const
193 {
194 return GetNode(index)->GetnodeType();
195 }
196
204 {
205 return m_pParent->appendChild(newItem);
206 }
207
215 CXmlNodePtr AppendNode(ENodeType type, LPCTSTR text)
216 {
217 return AppendNode(m_MakeNewNode(type, text));
218 }
219
227 CXmlNodePtr InsertNode(INDEX index, CXmlNodePtr newItem)
228 {
229 if ( GetLength() > index )
230 {
231 return m_pParent->insertBefore(newItem, GetNode(index).GetInterfacePtr());
232 }
233 return m_pParent->appendChild(newItem);
234 }
235
244 CXmlNodePtr InsertNode(INDEX index, ENodeType type, LPCTSTR text)
245 {
246 return InsertNode(index, m_MakeNewNode(type, text));
247 }
248
255 void ReplaceNode(INDEX index1, INDEX index2)
256 {
257 m_pParent->replaceChild(GetNode(index1), GetNode(index2));
258 }
259
264 void RemoveNode(INDEX index)
265 {
266 m_pParent->removeChild(GetNode(index));
267 }
268
269private:
270 friend class CXmlTest;
271};
272
273
274
293{
294 MSXML::IXMLDOMAttributePtr m_pAttr;
295
296public:
297
302 CXmlAttribute(MSXML::IXMLDOMAttributePtr p) : m_pAttr(p)
303 {
304 }
305
312 bool IsValid(void) const
313 {
314 return m_pAttr != NULL;
315 }
316
323 MSXML::IXMLDOMAttributePtr operator->(void)
324 {
325 return m_pAttr;
326 }
327
332 CStr GetName(void) const
333 {
334 _bstr_t r = m_pAttr->Getname();
335 return CStr(LPCTSTR(r));
336 }
337
342 CStr GetValue(void) const
343 {
344 _bstr_t r = m_pAttr->GetValue();
345 return CStr(LPCTSTR(r));
346 }
347
353 void PutValue(LPCTSTR text)
354 {
355 m_pAttr->PutValue(text);
356 }
357
358private:
359 friend class CXmlTest;
360};
361
362
363
377{
378 HRESULT m_initRes;
379protected:
380
382
389 {
390 m_initRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
391 }
392
394 virtual ~CAbstractXmlNode(void)
395 {
396 if ( m_initRes == S_OK )
397 {
398 ::CoUninitialize();
399 }
400 }
401
402public:
403
411 {
412 return m_pNode;
413 }
414
421 bool IsValid(void) const
422 {
423 return m_pNode != NULL;
424 }
425
429 void Invalid(void)
430 {
431 m_pNode = NULL;
432 }
433
440 CStr GetNodeName(void) const
441 {
442 if ( ! IsValid() ) { return CStr(); }
443 _bstr_t r = m_pNode->GetnodeName();
444 return LPCTSTR(r);
445 }
446
453 CStr GetNodeValue(void) const
454 {
455 if ( ! IsValid() ) { return CStr(); }
456 _bstr_t r = m_pNode->GetnodeValue();
457 return LPCTSTR(r);
458 }
459
465 void Remove(void)
466 {
467 m_pNode->GetparentNode()->removeChild(m_pNode);
468 m_pNode = NULL;
469 }
470
477 {
478 return IsValid() ? m_pNode->GetparentNode() : NULL;
479 }
480
487 {
488 return IsValid() ? m_pNode->GetnextSibling() : NULL;
489 }
490
499 {
500 CStr str;
501 if ( IsValid() )
502 {
503 CXmlNodePtr n = m_pNode->GetparentNode();
504 while ( n != NULL )
505 {
506 if ( n->GetnodeType() == MSXML::NODE_DOCUMENT )
507 {
508 break;
509 }
510 str = CStr::Fmt(_T("/%s%s"), LPCTSTR(n->GetnodeName()), str);
511 n = n->GetparentNode();
512 }
513 }
514 return str;
515 }
516
517private:
518 friend class CXmlTest;
519};
520
521
522
542{
543 DEFSUPER(CAbstractXmlNode);
544public:
545
550 CXmlNode(CXmlNodePtr p) : _super(p)
551 {
552 }
553
571 MSXML::DOMNodeType GetNodeType(void) const
572 {
573 return IsValid() ? m_pNode->GetnodeType() : MSXML::DOMNodeType(MSXML::NODE_INVALID);
574 }
575
576private:
577 friend class CXmlTest;
578};
579
580
581
600{
601 DEFSUPER(CAbstractXmlNode);
602public:
603
608 CXmlText(void) : _super(NULL)
609 {
610 }
611
617 CXmlText(CXmlNode n) : _super(NULL)
618 {
619 if ( n.GetNodeType() == MSXML::NODE_TEXT )
620 {
621 m_pNode = n.operator ->();
622 }
623 }
624
631 {
632 if ( n.GetNodeType() == MSXML::NODE_TEXT )
633 {
634 m_pNode = n.operator ->();
635 }
636 else
637 {
638 m_pNode = NULL;
639 }
640 return *this;
641 }
642
649 CStr GetText(void) const
650 {
651 return GetNodeValue();
652 }
653
659 void Rename(LPCTSTR newName)
660 {
661 if ( GetText().IsEqual(newName) )
662 {
663 return;
664 }
665 CXmlNodePtr n = m_pNode->GetownerDocument()->createTextNode(newName);
666 m_pNode->GetparentNode()->replaceChild(n, m_pNode);
667 m_pNode = n;
668 }
669
676 CXmlText Clone(void) const
677 {
678 return m_pNode->cloneNode(VARIANT_FALSE);
679 }
680
681private:
682 friend class CXmlTest;
683};
684
685
686
705{
706 DEFSUPER(CAbstractXmlNode);
707public:
708
713 CXmlComment(void) : _super(NULL)
714 {
715 }
716
722 CXmlComment(CXmlNode n) : _super(NULL)
723 {
724 if ( n.GetNodeType() == MSXML::NODE_COMMENT )
725 {
726 m_pNode = n.operator ->();
727 }
728 }
729
736 {
737 if ( n.GetNodeType() == MSXML::NODE_COMMENT )
738 {
739 m_pNode = n.operator ->();
740 }
741 else
742 {
743 m_pNode = NULL;
744 }
745 return *this;
746 }
747
754 CStr GetComment(void) const
755 {
756 return GetNodeValue();
757 }
758
764 void Rename(LPCTSTR newName)
765 {
766 if ( GetComment().IsEqual(newName) )
767 {
768 return;
769 }
770 CXmlNodePtr n = m_pNode->GetownerDocument()->createComment(newName);
771 m_pNode->GetparentNode()->replaceChild(n, m_pNode);
772 m_pNode = n;
773 }
774
781 CXmlComment Clone(void) const
782 {
783 return m_pNode->cloneNode(VARIANT_FALSE);
784 }
785
786private:
787 friend class CXmlTest;
788};
789
790
791
811{
812 DEFSUPER(CAbstractXmlNode);
813protected:
814
815 MSXML::IXMLDOMNamedNodeMapPtr m_pAttr;
816
817public:
818
823 CXmlProcessingInstruction(void) : _super(NULL), m_pAttr(NULL)
824 {
825 }
826
833 {
834 if ( n.GetNodeType() == MSXML::NODE_PROCESSING_INSTRUCTION )
835 {
836 m_pNode = n.operator ->();
837 m_pAttr = m_pNode->Getattributes();
838 }
839 }
840
847 {
848 if ( n.GetNodeType() == MSXML::NODE_PROCESSING_INSTRUCTION )
849 {
850 m_pNode = n.operator ->();
851 m_pAttr = m_pNode->Getattributes();
852 }
853 else
854 {
855 m_pNode = NULL;
856 m_pAttr = NULL;
857 }
858 return *this;
859 }
860
866 long GetAttributeLength(void) const
867 {
868 if ( m_pAttr != NULL )
869 {
870 return m_pAttr->Getlength();
871 }
872 return 0;
873 }
874
881 CXmlAttribute GetAttribute(INDEX index) const
882 {
883 if ( m_pAttr != NULL )
884 {
885 return m_pAttr->Getitem(static_cast<long>(index));
886 }
887 return CXmlAttribute(NULL);
888 }
889
897 {
898 if ( m_pAttr != NULL )
899 {
900 return m_pAttr->getNamedItem(name);
901 }
902 return CXmlAttribute(NULL);
903 }
904
911 CStr GetAttributeValue(LPCTSTR name) const
912 {
914 return a.IsValid() ? a.GetValue() : CStr();
915 }
916
925 CXmlAttribute SetAttribute(LPCTSTR name, LPCTSTR value)
926 {
927 if ( IsValid() && m_pAttr != NULL )
928 {
929 MSXML::IXMLDOMDocumentPtr pDoc = m_pNode->GetownerDocument();
930 MSXML::IXMLDOMAttributePtr p = pDoc->createAttribute(name);
931 p->PutValue(value);
932 return m_pAttr->setNamedItem(p);
933 }
934 return CXmlAttribute(NULL);
935 }
936
944 bool RemoveAttribute(LPCTSTR name)
945 {
946 if ( m_pAttr != NULL )
947 {
948 CXmlNodePtr p = m_pAttr->removeNamedItem(name);
949 return p != NULL;
950 }
951 return false;
952 }
953
954private:
955 friend class CXmlTest;
956};
957
958
959
980{
982public:
983
988 CXmlElement(void) : _super()
989 {
990 }
991
997 CXmlElement(CXmlNode n) : _super()
998 {
999 if ( n.GetNodeType() == MSXML::NODE_ELEMENT )
1000 {
1001 m_pNode = n.operator ->();
1002 m_pAttr = m_pNode->Getattributes();
1003 }
1004 }
1005
1012 {
1013 if ( n.GetNodeType() == MSXML::NODE_ELEMENT )
1014 {
1015 m_pNode = n.operator ->();
1016 m_pAttr = m_pNode->Getattributes();
1017 }
1018 else
1019 {
1020 m_pNode = NULL;
1021 m_pAttr = NULL;
1022 }
1023 return *this;
1024 }
1025
1031 void Rename(LPCTSTR newName)
1032 {
1033 if ( GetNodeName().IsEqual(newName) )
1034 {
1035 return;
1036 }
1037 CXmlNodePtr n = m_pNode->GetownerDocument()->createElement(newName);
1038 // 属性引越し
1039 MSXML::IXMLDOMNamedNodeMapPtr pOldAttrList = m_pNode->Getattributes();
1040 if ( NULL != pOldAttrList )
1041 {
1042 MSXML::IXMLDOMNamedNodeMapPtr pNewAttrList = n->Getattributes();
1043 MSXML::IXMLDOMAttributePtr pAttr;
1044 while ( (pAttr = pOldAttrList->nextNode()) != NULL )
1045 {
1046 pNewAttrList->setNamedItem(pAttr->cloneNode(VARIANT_TRUE));
1047 }
1048 }
1049 // ノード引越し
1050 MSXML::IXMLDOMNodePtr pChild;
1051 while ( (pChild = m_pNode->GetfirstChild()) != NULL )
1052 {
1053 n->appendChild(pChild);
1054 }
1055 // 入れ替え
1056 MSXML::IXMLDOMNodePtr p = m_pNode->GetparentNode();
1057 p->replaceChild(n, m_pNode);
1058 m_pNode = n;
1059 }
1060
1067 bool HasChildNodes(void) const
1068 {
1069 if ( ! IsValid() ) { return false; }
1070 return VARIANT_FALSE != m_pNode->hasChildNodes();
1071 }
1072
1079 {
1080 return m_pNode->GetfirstChild();
1081 }
1082
1089 {
1090 return CXmlNodeList(m_pNode->GetchildNodes(), m_pNode);
1091 }
1092
1099 CXmlNodeList SelectNodes(LPCTSTR expression) const
1100 {
1101 return CXmlNodeList(m_pNode->selectNodes(expression), m_pNode);
1102 }
1103
1110 CXmlNode SelectSingleNode(LPCTSTR expression) const
1111 {
1112 return CXmlNode(m_pNode->selectSingleNode(expression));
1113 }
1114
1121 {
1122 return m_pNode->GetparentNode();
1123 }
1124
1133 CXmlNode Clone(bool boIsDeep = true) const
1134 {
1135 return m_pNode->cloneNode(boIsDeep ? VARIANT_TRUE : VARIANT_FALSE);
1136 }
1137
1145 {
1147 }
1148
1156 {
1158 }
1159
1167 {
1169 }
1170
1181 {
1182 return m_pNode->appendChild(a.operator ->());
1183 }
1184
1185private:
1186 friend class CXmlTest;
1187};
1188
1189
1190
1210{
1211 DEFSUPER(CXmlElement);
1212public:
1213
1219 CXmlDocumentFragment(MSXML::IXMLDOMDocumentFragmentPtr n) : _super()
1220 {
1221 if ( n->GetnodeType() == MSXML::NODE_DOCUMENT_FRAGMENT )
1222 {
1223 m_pNode = n;
1224 m_pAttr = m_pNode->Getattributes();
1225 }
1226 }
1227};
1228
1229
1230
1258{
1259 MSXML::IXMLDOMDocumentPtr m_pDoc;
1260 HRESULT m_initRes;
1262 void m_Release(void)
1263 {
1264 m_pDoc = NULL;
1265 }
1267 void m_Init(void)
1268 {
1269 m_Release();
1270#ifndef _TnbXML_MsXml6_ENABLE
1271 MSXML::IXMLDOMDocumentPtr p(__uuidof(MSXML::DOMDocument));
1272#else
1273 MSXML::IXMLDOMDocumentPtr p(__uuidof(MSXML::DOMDocument60));
1274#endif
1275 m_pDoc = p;
1276 p->put_async(VARIANT_FALSE);
1277 }
1286 bool m_Load(LPCTSTR text, bool isFile)
1287 {
1288 m_Init();
1289 _bstr_t bstr = text;
1290 VARIANT_BOOL varResult;
1291 if ( isFile )
1292 {
1293 varResult = m_pDoc->load(_variant_t(bstr));
1294 }
1295 else
1296 {
1297 varResult = m_pDoc->loadXML(bstr);
1298 }
1299 bool r = ( VARIANT_FALSE != varResult );
1300 if ( ! r )
1301 {
1302 Invalid();
1303 }
1304 return r;
1305 }
1306
1307public:
1308
1310 CXmlDocument(void) : m_pDoc(NULL)
1311 {
1312 m_initRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
1313 }
1314
1316 virtual ~CXmlDocument(void)
1317 {
1318 m_Release();
1319 if ( m_initRes == S_OK )
1320 {
1321 ::CoUninitialize();
1322 }
1323 }
1324
1331 bool IsValid(void) const
1332 {
1333 return m_pDoc != NULL;
1334 }
1335
1340 void Invalid(void)
1341 {
1342 m_pDoc = NULL;
1343 }
1344
1349 DWORD GetLastError(void) const
1350 {
1351 return m_pDoc->GetparseError()->GeterrorCode();
1352 }
1353
1359 {
1360 CStr r;
1361 MSXML::IXMLDOMParseErrorPtr pError = m_pDoc->GetparseError();
1362 if ( pError->GeterrorCode() != 0 )
1363 {
1364 _bstr_t bstr = pError->Getreason();
1365 r = LPCTSTR(bstr);
1366 }
1367 return r;
1368 }
1369
1378 void Initialize(LPCTSTR lpszRootElementName, LPCTSTR lpszComment = NULL, LPCTSTR lpszTarget = NULL, LPCTSTR lpszData = NULL)
1379 {
1380 m_Init();
1381 if ( lpszTarget != NULL && lpszData != NULL )
1382 {
1383 CXmlNodePtr pNode = m_pDoc->createProcessingInstruction(lpszTarget, lpszData);
1384 m_pDoc->appendChild(pNode);
1385 }
1386 if ( lpszComment != NULL )
1387 {
1388 CXmlNodePtr pNode = m_pDoc->createComment(lpszComment);
1389 m_pDoc->appendChild(pNode);
1390 }
1391 CXmlNodePtr pNode = m_pDoc->createElement(lpszRootElementName);
1392 m_pDoc->appendChild(pNode);
1393 }
1394
1401 void InitializeXml(LPCTSTR lpszRootElementName, LPCTSTR lpszComment = NULL)
1402 {
1403 m_Init();
1404 CXmlNodePtr pNode = m_pDoc->createProcessingInstruction(_T("xml"), _T("version='1.0'"));
1405 m_pDoc->appendChild(pNode);
1406 if ( lpszComment != NULL )
1407 {
1408 CXmlNodePtr pNode = m_pDoc->createComment(lpszComment);
1409 m_pDoc->appendChild(pNode);
1410 }
1411 pNode = m_pDoc->createElement(lpszRootElementName);
1412 m_pDoc->appendChild(pNode);
1413 }
1414
1421 bool LoadFile(LPCTSTR lpszFileName)
1422 {
1423 return m_Load(lpszFileName, true);
1424 }
1425
1432 bool LoadXml(LPCTSTR lpszXml)
1433 {
1434 return m_Load(lpszXml, false);
1435 }
1436
1446 bool SaveFile(LPCTSTR lpszFileName, bool boIsUtf8 = true) const
1447 {
1448 _bstr_t bstr = lpszFileName;
1450 if ( pi.IsValid() )
1451 {
1452 pi.SetAttribute(_T("encoding"), (boIsUtf8 ? _T("UTF-8") : _T("SJIS")));
1453 }
1454 return SUCCEEDED(m_pDoc->save(bstr));
1455 }
1456
1457
1458#ifdef _TnbXML_MsXml6_ENABLE
1459
1472 bool SaveFileEx(LPCTSTR lpszFileName, bool boIsUtf8 = true) const
1473 {
1474 IStreamPtr stream = NULL;
1475 try
1476 {
1477 typedef HRESULT (WINAPI *P_SHCreateStreamOnFileW)(LPCWSTR, DWORD, IStream**);
1478 CDynamicFuncT<P_SHCreateStreamOnFileW>("shlwapi.dll", "SHCreateStreamOnFileW")()(
1479 CUnicode(lpszFileName),
1480 STGM_READWRITE | STGM_SHARE_DENY_WRITE | STGM_CREATE,
1481 &stream
1482 );
1483 }
1484 catch(CNullPointerException& e)
1485 {
1486 e.OnCatch();
1487 return false;
1488 }
1489 if ( stream == NULL )
1490 {
1491 return false;
1492 }
1493// MSXML2::IMXWriterPtr wrt(__uuidof(MSXML2::MXXMLWriter));
1494 MSXML2::IMXWriterPtr wrt(__uuidof(MSXML2::MXXMLWriter60));
1495 wrt->put_version(L"1.0");
1496 wrt->put_encoding(boIsUtf8 ? L"UTF-8" : L"SJIS");
1497 wrt->put_indent(VARIANT_TRUE);
1498 wrt->Putstandalone(VARIANT_TRUE);
1499 wrt->put_output(_variant_t(IUnknownPtr(stream).GetInterfacePtr()));
1500 MSXML2::ISAXXMLReaderPtr rdr(__uuidof(MSXML2::SAXXMLReader60));
1501// MSXML2::ISAXXMLReaderPtr rdr(__uuidof(MSXML2::SAXXMLReader));
1502 rdr->putContentHandler(MSXML2::ISAXContentHandlerPtr(wrt));
1503 _variant_t vinput = IUnknownPtr(m_pDoc).GetInterfacePtr();
1504 return SUCCEEDED(rdr->parse(vinput));
1505 }
1506
1507#endif
1508
1509
1516 CStr ToString(void) const
1517 {
1518 _bstr_t str = m_pDoc->Getxml();
1519 return CStr(LPCTSTR(str));
1520 }
1521
1528 {
1529 return CXmlNodeList(m_pDoc->GetchildNodes(), m_pDoc, m_pDoc);
1530 }
1531
1538 {
1539 const CXmlNodeList& list = GetChildNodes();
1540 loop ( i, list.GetLength() )
1541 {
1542 if ( list.GetNodeType(i) == MSXML::NODE_PROCESSING_INSTRUCTION )
1543 {
1544 return list.GetNode(i);
1545 }
1546 }
1548 }
1549
1556 {
1557 const CXmlNodeList& list = GetChildNodes();
1558 loop ( i, list.GetLength() )
1559 {
1560 if ( list.GetNodeType(i) == MSXML::NODE_ELEMENT )
1561 {
1562 return list.GetNode(i);
1563 }
1564 }
1565 return CXmlElement();
1566 }
1567
1573 {
1574 return CXmlDocumentFragment(m_pDoc->createDocumentFragment());
1575 }
1576
1584 {
1585 return CXmlNodeList(m_pDoc->getElementsByTagName(name), m_pDoc, m_pDoc);
1586 }
1587
1594 CXmlNodeList SelectNodes(LPCTSTR expression) const
1595 {
1596 return CXmlNodeList(m_pDoc->selectNodes(expression), m_pDoc, m_pDoc);
1597 }
1598
1605 CXmlNode SelectSingleNode(LPCTSTR expression) const
1606 {
1607 return CXmlNode(m_pDoc->selectSingleNode(expression));
1608 }
1609
1610private:
1611 friend class CXmlTest;
1612};
1613
1614
1615
1616}; // TNB
1617
1618
#define loop(VAR, CNT)
loop構文.
Definition: TnbDef.h:343
動的関数管理関係のヘッダ
文字列管理関係のヘッダ
XML ノード管理基礎クラス
Definition: TnbXml.h:377
CXmlNodePtr GetParentNode(void) const
[取得] 親のノード取得.
Definition: TnbXml.h:476
CXmlNodePtr operator->(void)
[取得] ポインタハンドル取得.
Definition: TnbXml.h:410
CXmlNodePtr GetNextSibling(void) const
[取得] 隣のノード取得.
Definition: TnbXml.h:486
CStr GetElementFullPath(void) const
[作成] ルートからの Element名.
Definition: TnbXml.h:498
void Invalid(void)
[設定] 無効化.
Definition: TnbXml.h:429
bool IsValid(void) const
[確認] 有効確認.
Definition: TnbXml.h:421
CXmlNodePtr m_pNode
ノードクラスのポインタハンドル
Definition: TnbXml.h:381
CStr GetNodeValue(void) const
[取得] 値取得.
Definition: TnbXml.h:453
virtual ~CAbstractXmlNode(void)
デストラクタ
Definition: TnbXml.h:394
void Remove(void)
[削除] 自分自身を削除.
Definition: TnbXml.h:465
CStr GetNodeName(void) const
[取得] 名前取得.
Definition: TnbXml.h:440
CAbstractXmlNode(CXmlNodePtr p)
コンストラクタ
Definition: TnbXml.h:388
動的関数管理クラステンプレート
NULLポインタ例外
Definition: TnbException.h:172
static CStrT Fmt(const TCHAR *lpszFormat,...)
[作成] 書式付き文字列作成
Definition: TnbStr.h:1206
void OnCatch(void) const
[表示] 内容表示
Definition: TnbException.h:69
XML 属性管理クラス
Definition: TnbXml.h:293
CXmlAttribute(MSXML::IXMLDOMAttributePtr p)
コントラクタ
Definition: TnbXml.h:302
bool IsValid(void) const
[確認] 有効確認.
Definition: TnbXml.h:312
MSXML::IXMLDOMAttributePtr operator->(void)
[取得] ポインタハンドル取得.
Definition: TnbXml.h:323
CStr GetName(void) const
[取得] 名前取得.
Definition: TnbXml.h:332
void PutValue(LPCTSTR text)
[設定] 値設定.
Definition: TnbXml.h:353
CStr GetValue(void) const
[取得] 値取得.
Definition: TnbXml.h:342
XML Comment 管理クラス
Definition: TnbXml.h:705
CXmlComment(CXmlNode n)
コンストラクタ
Definition: TnbXml.h:722
CXmlComment(void)
コンストラクタ
Definition: TnbXml.h:713
void Rename(LPCTSTR newName)
[変更] 名前変更.
Definition: TnbXml.h:764
CXmlComment Clone(void) const
[作成] クローン作成.
Definition: TnbXml.h:781
CXmlComment & operator=(CXmlNode n)
[代入] 代入
Definition: TnbXml.h:735
CStr GetComment(void) const
[取得] Comment 取得.
Definition: TnbXml.h:754
XML DocumentFragment ノード管理クラス
Definition: TnbXml.h:1210
CXmlDocumentFragment(MSXML::IXMLDOMDocumentFragmentPtr n)
コンストラクタ
Definition: TnbXml.h:1219
XML ドキュメント管理クラス
Definition: TnbXml.h:1258
virtual ~CXmlDocument(void)
デストラクタ
Definition: TnbXml.h:1316
CXmlNode SelectSingleNode(LPCTSTR expression) const
[検索] 条件一致ノード検索.
Definition: TnbXml.h:1605
void Initialize(LPCTSTR lpszRootElementName, LPCTSTR lpszComment=NULL, LPCTSTR lpszTarget=NULL, LPCTSTR lpszData=NULL)
[操作] 初期化
Definition: TnbXml.h:1378
void Invalid(void)
[設定] 無効化.
Definition: TnbXml.h:1340
CXmlNodeList GetChildNodes(void) const
[取得] 子ノード群取得.
Definition: TnbXml.h:1527
CXmlNodeList GetElementsByTagName(LPCTSTR name) const
[検索] 条件一致ノード検索.
Definition: TnbXml.h:1583
bool SaveFile(LPCTSTR lpszFileName, bool boIsUtf8=true) const
[作成] XMLファイル作成
Definition: TnbXml.h:1446
bool IsValid(void) const
[確認] 有効確認.
Definition: TnbXml.h:1331
void InitializeXml(LPCTSTR lpszRootElementName, LPCTSTR lpszComment=NULL)
[操作] 初期化
Definition: TnbXml.h:1401
CXmlProcessingInstruction GetProcessingInstruction(void) const
[取得] ProcessingInstruction ノード取得.
Definition: TnbXml.h:1537
CStr GetLastErrorString(void) const
[取得] エラーコード文字列
Definition: TnbXml.h:1358
CXmlElement GetRootElement(void) const
[取得] Element ノード取得.
Definition: TnbXml.h:1555
CXmlNodeList SelectNodes(LPCTSTR expression) const
[検索] 条件一致ノード検索.
Definition: TnbXml.h:1594
CXmlDocumentFragment CreateDocumentFragment(void) const
[作成] DocumentFragment作成.
Definition: TnbXml.h:1572
CXmlDocument(void)
コンストラクタ
Definition: TnbXml.h:1310
CStr ToString(void) const
[作成] XMLテキスト作成
Definition: TnbXml.h:1516
bool LoadXml(LPCTSTR lpszXml)
[設定] XMLテキスト読込
Definition: TnbXml.h:1432
bool LoadFile(LPCTSTR lpszFileName)
[設定] XMLファイル読込
Definition: TnbXml.h:1421
DWORD GetLastError(void) const
[取得] エラーコード
Definition: TnbXml.h:1349
bool SaveFileEx(LPCTSTR lpszFileName, bool boIsUtf8=true) const
[作成] XMLファイル作成
Definition: TnbXml.h:1472
XML Element ノード管理クラス
Definition: TnbXml.h:980
CXmlNode SelectSingleNode(LPCTSTR expression) const
[検索] 条件一致ノード検索.
Definition: TnbXml.h:1110
bool HasChildNodes(void) const
[確認] 子ノード有無確認.
Definition: TnbXml.h:1067
CXmlElement & operator=(CXmlNode n)
[代入] 代入
Definition: TnbXml.h:1011
CXmlNode Clone(bool boIsDeep=true) const
[作成] クローン作成.
Definition: TnbXml.h:1133
CXmlElement(CXmlNode n)
コンストラクタ
Definition: TnbXml.h:997
CXmlComment AppendChildComment(LPCTSTR text)
[追加] コメント子ノード追加.
Definition: TnbXml.h:1144
CXmlNodeList GetChildNodes(void) const
[取得] 子ノード群取得.
Definition: TnbXml.h:1088
CXmlNode AppendChildNode(CAbstractXmlNode &a)
[追加] 子ノード追加.
Definition: TnbXml.h:1180
CXmlElement AppendChildElement(LPCTSTR text)
[追加] Element 子ノード追加.
Definition: TnbXml.h:1166
void Rename(LPCTSTR newName)
[変更] 名前変更.
Definition: TnbXml.h:1031
CXmlElement GetParentNode(void) const
[取得] 親 Element ノード取得.
Definition: TnbXml.h:1120
CXmlNodeList SelectNodes(LPCTSTR expression) const
[検索] 条件一致ノード検索.
Definition: TnbXml.h:1099
CXmlElement(void)
コンストラクタ
Definition: TnbXml.h:988
CXmlNode GetFirstChild(void) const
[取得] 最初の子ノード取得.
Definition: TnbXml.h:1078
CXmlText AppendChildText(LPCTSTR text)
[追加] テキスト子ノード追加.
Definition: TnbXml.h:1155
XML ノードリスト管理クラス
Definition: TnbXml.h:76
void RemoveNode(INDEX index)
[削除] ノード削除.
Definition: TnbXml.h:264
CXmlNodePtr InsertNode(INDEX index, ENodeType type, LPCTSTR text)
[追加] ノード追加.
Definition: TnbXml.h:244
size_t GetLength(void) const
[取得] 管理ノード数取得.
Definition: TnbXml.h:158
bool IsValid(void) const
[確認] 有効確認.
Definition: TnbXml.h:137
MSXML::DOMNodeType GetNodeType(INDEX index) const
[取得] ノードタイプ取得.
Definition: TnbXml.h:192
void ReplaceNode(INDEX index1, INDEX index2)
[操作] ノード入れ替え.
Definition: TnbXml.h:255
CXmlNodePtr InsertNode(INDEX index, CXmlNodePtr newItem)
[追加] ノード追加.
Definition: TnbXml.h:227
CXmlNodeList(MSXML::IXMLDOMNodeListPtr na, CXmlNodePtr pp, MSXML::IXMLDOMDocumentPtr dc=NULL)
コンストラクタ
Definition: TnbXml.h:126
CXmlNodePtr AppendNode(CXmlNodePtr newItem)
[追加] ノード追加.
Definition: TnbXml.h:203
ENodeType
ノード種類型
Definition: TnbXml.h:81
@ ELEMENT
Element
Definition: TnbXml.h:82
@ TEXT
文字列
Definition: TnbXml.h:83
@ COMMENT
コメント
Definition: TnbXml.h:84
CXmlNodePtr AppendNode(ENodeType type, LPCTSTR text)
[追加] ノード追加.
Definition: TnbXml.h:215
CXmlNodePtr GetNode(INDEX index) const
[取得] ノード取得.
Definition: TnbXml.h:169
MSXML::IXMLDOMNodeListPtr operator->(void)
[取得] ポインタハンドル取得.
Definition: TnbXml.h:148
XML ノード管理クラス
Definition: TnbXml.h:542
MSXML::DOMNodeType GetNodeType(void) const
[取得] ノードタイプ取得.
Definition: TnbXml.h:571
CXmlNode(CXmlNodePtr p)
コンストラクタ
Definition: TnbXml.h:550
XML ProcessingInstruction 管理クラス
Definition: TnbXml.h:811
CXmlProcessingInstruction & operator=(CXmlNode n)
[代入] 代入
Definition: TnbXml.h:846
CXmlProcessingInstruction(void)
コンストラクタ
Definition: TnbXml.h:823
CXmlProcessingInstruction(CXmlNode n)
コンストラクタ
Definition: TnbXml.h:832
CXmlAttribute GetAttributeByName(LPCTSTR name) const
[取得] 属性取得.
Definition: TnbXml.h:896
MSXML::IXMLDOMNamedNodeMapPtr m_pAttr
ノード名前マップクラスのポインタハンドル
Definition: TnbXml.h:815
bool RemoveAttribute(LPCTSTR name)
[設定] 属性削除.
Definition: TnbXml.h:944
CXmlAttribute SetAttribute(LPCTSTR name, LPCTSTR value)
[設定] 属性設定.
Definition: TnbXml.h:925
CStr GetAttributeValue(LPCTSTR name) const
[取得] 属性値取得.
Definition: TnbXml.h:911
CXmlAttribute GetAttribute(INDEX index) const
[取得] 属性取得.
Definition: TnbXml.h:881
long GetAttributeLength(void) const
[取得] 属性数取得.
Definition: TnbXml.h:866
XML Text 管理クラス
Definition: TnbXml.h:600
CStr GetText(void) const
[取得] TEXT 取得.
Definition: TnbXml.h:649
CXmlText Clone(void) const
[作成] クローン作成.
Definition: TnbXml.h:676
CXmlText(CXmlNode n)
コンストラクタ
Definition: TnbXml.h:617
void Rename(LPCTSTR newName)
[変更] 名前変更.
Definition: TnbXml.h:659
CXmlText(void)
コンストラクタ
Definition: TnbXml.h:608
CXmlText & operator=(CXmlNode n)
[代入] 代入
Definition: TnbXml.h:630
TNB::CStrT< WCHAR > CUnicode
UNICODE文字列クラス
Definition: TnbStr.h:1771
TNB::CStrT< TCHAR > CStr
文字列クラス
Definition: TnbStr.h:1785
TNB Library
Definition: TnbDoxyTitle.txt:2
MSXML::IXMLDOMNodePtr CXmlNodePtr
XML ノードポインタハンドルクラス
Definition: TnbXml.h:52