ホーム » 検索結果: xml 読込 2019

検索結果: xml 読込 2019

2024年5月
 1234
567891011
12131415161718
19202122232425
262728293031  

カテゴリー

アーカイブ

ブログ統計情報

  • 80,618 アクセス



xml の読込み – 3

2019/01 に書いた xml の読込み で,属性が次の様になっている場合うまく処理できないバグがあった.
attr=’”a” “b”‘
他にも !DOCTYPE があるとうまく処理できていなかった.
また,そのデータの出力(Save_xml)も attr=””a” “b”” となってうまくなかった.
xml 読込みバグ データ
parsexml.hxx
xml_out.hxx


https://jml.mish.work/index.php/cpp/xml.html

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Win10 VC 2005 で C1083 msxml.dll

今まで WinXP + VC 2005 だったプロジェクトを Win10 に持ってきてビルドすると,

1>------ ビルド開始: プロジェクト: i3DV, 構成: Debug Win32 ------
1>コンパイルしています...
1>MainFrm.cpp
1>t:\develop\_.src\__iwao\xml_ms_.hxx(21) : fatal error C1083: タイプ ライブラリ ファイルを開けません。'msxml.dll': No such file or directory
1>i3DVView.cpp
1>t:\develop\_.src\__iwao\xml_ms_.hxx(21) : fatal error C1083: タイプ ライブラリ ファイルを開けません。'msxml.dll': No such file or directory
  ...
1>コードを生成中...
1>i3DV - エラー 16、警告 0
========== ビルド: 0 正常終了、1 失敗、0 更新、0 スキップ ==========

Win10 には msxml.dll がないためエラーとなっている.
VC 2008 以降のプロジェクトは Win7 でビルドできる様にしていた ので問題ない.

#if (_WIN32_WINNT >= 0x0600)	// Vista
    #import	<msxml6.dll>       named_guids
    #define	MSXML              MSXML2
    #define	CLSID_DOMDocument  CLSID_DOMDocument60
#else
    #import	<msxml.dll>        named_guids
#endif

WinXP 環境でも msxml6.dll は存在しているので,_MSC_VER>=1400 で判断する様に変更.

#if (_MSC_VER >=  1400)	// VC 2005
    #import	<msxml6.dll>       named_guids
    #define	MSXML              MSXML2
    #define	CLSID_DOMDocument  CLSID_DOMDocument60
#else
    #import	<msxml.dll>        named_guids
#endif

'msxml.dll': No such file or directory への対応


msxml.dll を使用しない方法 で書き直し
https://jml.mish.work/index.php/cpp/xml.html


Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

xml の読込み – 2

昨日の xml 読込み で,データが大きい場合に比例ではなく極端に遅くなる?
それで,次の様なコードで計測してみた.

bool Test (c_tstring& str)
{
    for (size_t index=0 ; index<str.size() ; index++) {
        ElapseTime et ;
        tstring s_str = ::Parse_xml_quot(str,_T('|'), &index) ;
        std::cerr << ::To_tstring_Ki(long(s_str.size())) << _T("\t") << et.GetElapse() << std::endl ;
        }
    return true ;
    }

bool Test (void)
{
    tstring outPath = ::Get_i_Tools_tmp_date() ;
    tstring now_hms = ::Now_Format(_T("%H%M%S")) ;
    tstring out_txt = ::Path_AddLastSP(outPath) + now_hms + _T(".txt") ;
    tstring outrtxt = ::Path_AddLastSP(outPath) + now_hms + _T("_.txt") ;
    tstring str ;
    {
        v_tstring strAry ;
        {
            tstring str_1000 ;
            {
                tstring str_10 = _T("0123456789") ;
                for (long indexS=0 ; indexS<100 ; indexS++) {
                    str_1000 += str_10 ;
                    }
                }
            for (long index=0 ; index<2000 ; index++) {
                strAry.push_back(str_1000) ;
                }
            }
        str = ::String_Join_Line(strAry) ;
        }
    str[0] = _T('|') ;
    str += _T('|') ;
    size_t len = str.length() ;
    while (len > 100) {
        len = len/2 ;
        str[len-0] = _T('|') ;
        str[len-1] = _T('|') ;
        }
    {
        tstring tmp = str ;
        v_tstring tmpAry = ::String_Split(tmp.c_str(),false) ;
        tmpAry = ::SkipEmpty(tmpAry) ;
        str = ::String_Join_Line(tmpAry) ;
        }
    {
        ::SaveUTF8(out_txt.c_str(),str) ;
        ::Test(str) ;
        }
    {
        tstring rev = str ;
        {
            std::reverse(rev.begin(),rev.end()) ;
            v_tstring revAry = ::String_Split(rev.c_str(),false) ;
            revAry = ::SkipEmpty(revAry) ;
            rev = ::String_Join_Line(revAry) ;
            }
        ::SaveUTF8(outrtxt.c_str(),rev) ;
        ::Test(rev) ;
        }
    return true ;
    }

DS116 では,比例と思われる.

login as: Iwao
Iwao@DS116's password:
Iwao@DS116:~$ source ./set_ds_inc.sh
Iwao@DS116:~$ cd gcc_test/Test/T_P_xm_q/
Iwao@DS116:~/gcc_test/Test/T_P_xm_q$ g++ T_P_xm_q.cpp
Iwao@DS116:~/gcc_test/Test/T_P_xm_q$ ll
total 204
drwxrwxrwx+  2 Iwao users   4096 Jan  8 14:10 .
drwxrwxrwx+ 10 Iwao users   4096 Jan  8 14:09 ..
-rwxrwxrwx   1 Iwao users 183528 Jan  8 14:10 a.out
-rwxrwxrwx+  1 Iwao users   3009 Jan  8 13:59 T_P_xm_q.cpp
Iwao@DS116:~/gcc_test/Test/T_P_xm_q$ ./a.out
     61         0.000384092
     61         6.10352e-05
    122         5.31673e-05
    245         5.19753e-05
    489         6.29425e-05
    979         8.70228e-05
  1.91 K        0.000140905
  3.82 K        0.000212908
  7.64 K        0.000381947
 15.29 K        0.000729799
 30.58 K        0.00145721
 61.16 K        0.0028069
122.32 K        0.00562811
244.63 K        0.011224
489.26 K        0.0223849
978.52 K        0.0462639
      0         5.38826e-05
      0         3.91006e-05
978.52 K        0.045109
489.26 K        0.022413
244.63 K        0.0112309
122.32 K        0.00556397
 61.16 K        0.00286198
 30.58 K        0.00143504
 15.29 K        0.000734806
  7.64 K        0.000383139
  3.82 K        0.000211
  1.91 K        0.000123024
    979         8.51154e-05
    489         6.19888e-05
    245         5.00679e-05
    122         4.3869e-05
     61         4.00543e-05
     61         3.91006e-05
      0         3.31402e-05
      0         3.31402e-05
Iwao@DS116:~/gcc_test/Test/T_P_xm_q$

VC 6 は比例でなく,もっとかかっている.VC 14 では問題ない.VC 8 以降?は大丈夫だと思う.

C:\Users\Iwao>C:\Users\Iwao\AppData\Local\Temp\MICS.tmp\Temp\Test.exe\T_P_xm_q.exe
     61         0
     61         0
    122         0
    245         0
    489         0
    979         0
  1.91 K        0
  3.82 K        0
  7.64 K        0
 15.29 K        0
 30.58 K        0.016
 61.16 K        0.016
122.32 K        0.109
244.63 K        0.531
489.26 K        2.433
978.52 K        14.68
      0         0
      0         0
978.52 K        14.664
489.26 K        1.342
244.63 K        0.374
122.32 K        0.125
 61.16 K        0.016
 30.58 K        0.015
 15.29 K        0
  7.64 K        0
  3.82 K        0
  1.91 K        0
    979         0
    489         0
    245         0
    122         0
     61         0
     61         0
      0         0
      0         0

C:\Users\Iwao>

parse_xml_quot をグラフ化
修正のコードは,

tstring Parse_xml_quot (c_tstring& str,const TCHAR qm,size_t* index)
{
    tstring q_str ;
    if (*index < str.length()) {
        TCHAR c = str[*index] ;
        if (c == qm) {
            /*
            q_str += c ;
            for (size_t indexQ=*index+1 ; indexQ<str.size() ; indexQ++) {
                TCHAR cq = str[indexQ] ;
                q_str += cq ;
                if (cq == qm) {
                    *index = indexQ ;
                    break ;
                    }
                }
            */
            size_t pos = ::String__Find(str,qm,*index+1) ;
            if (pos == tstring::npos) {
                q_str = str.substr(*index) ;
                *index = str.length() ;
                }
            else {
                size_t q_len = pos+1 - *index ;
                q_str = str.substr(*index,q_len) ;
                *index = pos ;
                }
            }
        }
    return q_str ;
    }

parsexml.hxx


2019/06/06
2019/01 のコードは属性の値のネスト(attr='”a” “b”‘)に対応できてないバグあり.


https://jml.mish.work/index.php/cpp/xml.html

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

xml の読込み

幾つかの xml データを読んでみると,データにより msxml.dll を使用したときに比べて明らかに遅い.

bool Test (LPCTSTR pathName)
{
    tstring outPath = ::Get_i_Tools_tmp_date() ;
    tstring now_hms = ::Now_Format(_T("_%M%S")) ;
    tstring out_xml = ::Path_AddLastSP(outPath) + ::Path_GetName(pathName) + now_hms + _T(".o.xml") ;
    tstring new_xml = ::Path_AddLastSP(outPath) + ::Path_GetName(pathName) + now_hms + _T(".n.xml") ;
    {
        ElapseTime eto ;
        Xml_E xml = ::Xml_Import(pathName) ;
        std::cerr << eto.GetElapse() << std::endl ;
        Xml_Out::Export(xml,out_xml.c_str()) ;
        }
    {
        ElapseTime etn ;
        Xml_E xml = ::Load_xml_2018_12(pathName) ;
        std::cerr << etn.GetElapse() << std::endl ;
        Xml_Out::Export(xml,new_xml.c_str()) ;
        }
    return true ;
    }

データは次の様な x3d で,5 倍くらいかかる.

Parse_xml で時間がかかる x3d
Parse_xml で時間がかかる x3d

x3d の場合は,属性の値が長い.
そのため次のコード部分( q_str+=cq )がうまくない.

tstring Parse_xml_quot (c_tstring& str,const TCHAR qm,size_t* index)
{
    tstring q_str ;
    if (*index < str.length()) {
        TCHAR c = str[*index] ;
        if (c == qm) {
            q_str += c ;
            for (size_t indexQ=*index+1 ; indexQ<str.size() ; indexQ++) {
                TCHAR cq = str[indexQ] ;
                q_str += cq ;
                if (cq == qm) {
                    *index = indexQ ;
                    break ;
                    }
                }
            }
        }
    return q_str ;
    }

https://jml.mish.work/index.php/cpp/xml.html

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

C1083 msxml.dll

WinXP + VC 2005 環境のプロジェクトを,Win7 + VC 2008 でビルドすると,
\\devxp\…\xml_ms_.hxx(15) : fatal error C1083: タイプ ライブラリ ファイルを開けません。
‘msxml.dll’: No such file or directory
検索すると,
XML file parsing in Visual Studio 2008 & Windows 7


2014/08/19 追記
Win8 + VC 2012 でビルドすると
  \\DevS\…\Xml_MS_.hxx(329): error C2039: ‘CLSID_DOMDocument’ : ‘MSXML2’ のメンバーではありません。
これで良いのかはわかってないが,#define CLSID_DOMDocument CLSID_DOMDocument60 を追加.
  #if (_WIN32_WINNT >= 0x0600)
    #import <msxml6.dll> named_guids
    #define MSXML MSXML2
    #define CLSID_DOMDocument CLSID_DOMDocument60
  #else
    #import <msxml.dll> named_guids
  #endif
 
2019/06/29 Win10 VC 2005 で C1083 msxml.dll


2019/01 C++ と STL の範囲で書き直し

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

C++ System::Xml::XmlReader

Visual C++ を使用して、ファイルから XML データを読み取る
Netting C++ XML による構成
XmlNode メンバ
  XmlNode.Attributes プロパティ
  XmlNode.ChildNodes プロパティ


System::Xml を利用した読込のコードを作成していて,テスト用のコードで
—— ビルド開始: プロジェクト: L_xml_I, 構成: Debug Win32 ——
コンパイルしています…
L_xml_I.cpp
.\L_xml_I.cpp(182) : error C2039: ‘GetTempPathW’ : ‘System::IO::Path’ のメンバではありません。
c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll : ‘System::IO::Path’ の宣言を確認してください。
.\L_xml_I.cpp(182) : error C2660: ‘GetTempPathW’ : 関数に 0 個の引数を指定できません。
L_xml_I – エラー 2、警告 0
========== ビルド: 0 正常終了、1 失敗、0 更新、0 スキップ ==========
  Windows.h をインクルードしてはいけない?
  使用する前?に以下を追加.
    #undef GetTempPath


2020/07 https://jml.mish.work/index.php/cpp/xml.html


2019/01 C++ と STL の範囲で書き直し
リンク先に msxml.dll などを使用しない C++ で書いたコードを置いています.


2019/08 System.Xml.dll と msxml.dll を使用したコードへのリンクを追加
xml_base.hxx
Str_CLI.hxx
Xml_CLI.hxx
Xml_MS_.hxx
Xml_In.hxx

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.