Print Page | Close Window

how to write data to CXTPPropExchangeXMLNode

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Syntax Edit
Forum Description: Topics Related to Codejock Syntax Edit
URL: http://forum.codejock.com/forum_posts.asp?TID=24048
Printed Date: 28 April 2024 at 7:32pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: how to write data to CXTPPropExchangeXMLNode
Posted By: yangyanhui
Subject: how to write data to CXTPPropExchangeXMLNode
Date Posted: 08 September 2020 at 4:40am
now I can read data from CXTPPropExchangeXMLNode using PX_STRING but I do not know how to write data into it. I have tried PX_STRING to write but failed



Replies:
Posted By: mgampi
Date Posted: 08 September 2020 at 5:09am
Hi;
Here's a code snipped that shows how to store. Keep in mind that you have to write all items you want to put into the XML file:

        CXTPPropExchangeXMLNode px(FALSE, 0, _T("Settings"));

        if (px.OnBeforeExchange())
        {
            CXTPPropExchangeSection pxSubNode1(px.GetSection(_T("Service")));
            VERIFY(PX_Long(&pxSubNode1, _T("TraceLevel"), TraceLevel_, logINFO));
            VERIFY(PX_String(&pxSubNode1, _T("User"),    TheUser));
            VERIFY(PX_String(&pxSubNode1, _T("DB-Service"),  TheService));
            VERIFY(PX_Long(&pxSubNode1, _T("DB-Interval"), Interval_));
            CXTPPropExchangeSection pxSubNode2(px.GetSection(_T("Parameters")));
            VERIFY(PX_Bool(&pxSubNode2, _T("ExtendedSampleCount"), UseExtendedSampleCount_, FALSE));
            VERIFY(PX_Bool(&pxSubNode2, _T("ShowEmptyRows"), ShowEmptyRows_, FALSE));
            VERIFY(PX_Bool(&pxSubNode2, _T("InvalidateHeatIfNoConsumption"), InvalidateHeatIfNoConsumption_, FALSE));

            if(!CreateDirectory(pszPath, nullptr))             
            {
                if (GetLastError()!=ERROR_ALREADY_EXISTS) {
                    return false;
                }
            }
            _tcscat_s(pszPath, _T("\\Options.xml"));
            if (px.SaveToFile(pszPath)==S_OK)
                return true;
        }

Hope this helps.


-------------
Martin

Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net