Print Page | Close Window

CXTPPropExchangeXMLNode & CompactMode

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=12009
Printed Date: 04 October 2024 at 11:25pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTPPropExchangeXMLNode & CompactMode
Posted By: jimmy
Subject: CXTPPropExchangeXMLNode & CompactMode
Date Posted: 28 August 2008 at 10:22am
Hello,

What is CompactMode ?
Why do i need this ?

i will only read a small xml file (LoadFromFile) and retrive Name with
PX_String( &px, "Name", strName, "");
But i don't get Name.
After i set CompactMode="1" , it work.
Why is this so ?

<?xml version="1.0" encoding="UTF-8"?>
<FB Name="AND" Comment="Some Comment" Revision="1.0" FolderPos="1" >
    <Outputs>
        <Out Name="OUT" DataType="bool" Initialized="true"/>
    </Outputs>
</FB>

  Jimmy




Replies:
Posted By: Oleg
Date Posted: 28 August 2008 at 1:23pm
CompactMode  switch way to store data:
 
with compact mode:
 
<FB Name="AND" />
 
without:
<FB> <Name>AND</Name> </FB>


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: jimmy
Date Posted: 29 August 2008 at 5:46am
Hi,

Mean that i can't use this ?

<FB Name="AND">
  <Input Name="Input1>Some Text</Input>
  <Input Name="Input1>Some other Text</Input>
</FB>

Here i have attribute (Name) and other text.

  Jimmy




Posted By: Oleg
Date Posted: 29 August 2008 at 4:12pm
With Compact mode can: PX_String( &px, "", strName, "");


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: jimmy
Date Posted: 29 August 2008 at 6:11pm
Thanks

  Jimmy



Posted By: cpede
Date Posted: 30 August 2008 at 7:10am
Sorry, but can you be a bit more precise?
How can I read the compact name tag?
And what if I have multiple compact tags? And mixing?
 
cpede


Posted By: jimmy
Date Posted: 01 September 2008 at 6:51am
Is there a simple way to enable ompact mode without CompactMode attribute  ?

  Jimmy

Now i do this
class CXTPPropExchangeXMLNodeEx : public CXTPPropExchangeXMLNode
{
public:
    CXTPPropExchangeXMLNodeEx(BOOL bLoading, CXTPDOMNodePtr xmlParentNode, LPCTSTR lpszSection)
        : CXTPPropExchangeXMLNode(bLoading, xmlParentNode, lpszSection)
    {
    }

    bool DeleteAttr(LPCTSTR lpszEntry)
    {
        USES_CONVERSION;
        CXTPDOMNodePtr xmlNodeEntryPtr;

        XTPXML::IXMLDOMNamedNodeMapPtr map;
        m_xmlSectionNode->get_attributes(&map);
        HRESULT hr = map->removeNamedItem(CT2BSTR(lpszEntry), &xmlNodeEntryPtr);
        if (FAILED(hr))
            return false;
        return true;
    }
    virtual BOOL OnBeforeExchange()
    {
        BOOL bOk = __super::OnBeforeExchange();
        SetCompactMode(TRUE);
        return bOk;
    }
};


Posted By: cpede
Date Posted: 03 September 2008 at 4:54am
Please, how do I mix Compact modes in one XML file?
 
-cpede


Posted By: jimmy
Date Posted: 03 September 2008 at 5:40am
Hi,

i think, if compacteMode is enabled, you can
access with
PX_String( &px, "AttrName", strName, "");a attribute entry and
with
PX_String( &px, "", strName, ""); you can access the normal text
<Input AttrName="AttributeValue">Normal Text</Input>

  Jimmy



Posted By: cpede
Date Posted: 03 September 2008 at 6:04am
But what if Compact mode is NOT enabled, how do I access the attributes?
I guess that this is the most normal case for external XML files, since the Compact attribute/tag is something invented by CodeJock?
 
-cpede


Posted By: cpede
Date Posted: 01 November 2016 at 7:16am
Is this implemented in v17.3?

Can I access compact attributes and nodes in CXTPPropExchangeXMLNode?

Maybe something like this:
<item tag="Hi">
CodeJock
</item>

CString sText1;
PX_String(&sec, _T("item/tag"), sText1);
CString sText2;
PX_String(&sec, _T("item"), sText2);

sText1 + " " +sText2 = "Hi CodeJock"

Quote
OK, I got a little wiser. The m_bCompactMode flag is set after the first initialize, e.g. the first time a PX_String is called. So, If someone loads an external XML which requires compact mode for reading, it is not enough to specify px.SetCompactMode(TRUE) after px.LoadFromFile(xmlfile), since this flag is reset by the first PX_String or alike. This is because CompactMode is a value set in the XML by CJ, and not as such a flag you can specify on load. So the trick is to do a dummy PX_String and thereafter set px.SetCompactMode(TRUE), to read the content of an external XML which is formatted with a mix of both attributes and nodes.

-cpede


-------------
Product: Xtreme ToolkitPro (22.1.0)
Platform: Windows 10 (x64)
Language: Visual Studio 2017 (C++)



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