英文:
How to get list of ledgers from tally using XML request filtered by name that contains a specified sub-text?
问题
我有以下的XML请求,它返回Tally中所有账户的列表。
<ENVELOPE>
<HEADER>
<VERSION>1</VERSION>
<TALLYREQUEST>Export</TALLYREQUEST>
<TYPE>Collection</TYPE>
<ID>Ledgers</ID>
</HEADER>
<BODY>
<DESC>
<STATICVARIABLES>
<SVEXPORTFORMAT>SysName:XML</SVEXPORTFORMAT>
</STATICVARIABLES>
<TDL>
<TDLMESSAGE>
<COLLECTION ISMODIFY="No" ISFIXED="No" ISINITIALIZE="No" ISOPTION="No" ISINTERNAL="No" NAME="Ledgers">
<TYPE>Ledger</TYPE>
<BELONGSTO>Yes</BELONGSTO>
<NATIVEMETHOD>Name</NATIVEMETHOD>
</COLLECTION>
</TDLMESSAGE>
</TDL>
</DESC>
</BODY>
</ENVELOPE>
现在在上面的代码中,我添加了以下筛选条件:
<TDLMESSAGE>
<COLLECTION ISMODIFY="No" ISFIXED="No" ISINITIALIZE="No" ISOPTION="No" ISINTERNAL="No" NAME="Ledgers">
<TYPE>Ledger</TYPE>
<BELONGSTO>Yes</BELONGSTO>
<NATIVEMETHOD>Name</NATIVEMETHOD>
<FILTERS>Site</FILTERS>
</COLLECTION>
<SYSTEM TYPE="Formulae" NAME="Site">$Name = 'Site'</SYSTEM>
</TDLMESSAGE>
所以,它的作用是检查是否有一个名为'Site'的账户。这个筛选条件完美地工作,只会给我返回一个名为'Site'的账户。但是,我需要的是一个包含词语'Site'的所有账户的列表,不论它们的名称中的位置如何。因此,我尝试使用LIKE操作符代替**=**。
<SYSTEM TYPE="Formulae" NAME="Site">$Name LIKE 'Site'</SYSTEM>
英文:
I have the following XML request that returns the list of all ledgers from Tally.
<ENVELOPE>
<HEADER>
<VERSION>1</VERSION>
<TALLYREQUEST>Export</TALLYREQUEST>
<TYPE>Collection</TYPE>
<ID>Ledgers</ID>
</HEADER>
<BODY>
<DESC>
<STATICVARIABLES>
<SVEXPORTFORMAT>SysName:XML</SVEXPORTFORMAT>
</STATICVARIABLES>
<TDL>
<TDLMESSAGE>
<COLLECTION ISMODIFY="No" ISFIXED="No" ISINITIALIZE="No" ISOPTION="No" ISINTERNAL="No" NAME="Ledgers">
<TYPE>Ledger</TYPE>
<BELONGSTO>Yes</BELONGSTO>
<NATIVEMETHOD>Name</NATIVEMETHOD>
</COLLECTION>
</TDLMESSAGE>
</TDL>
</DESC>
</BODY>
</ENVELOPE>
Now in the above code, I added a filter as follows:
<TDLMESSAGE>
<COLLECTION ISMODIFY="No" ISFIXED="No" ISINITIALIZE="No" ISOPTION="No" ISINTERNAL="No" NAME="Ledgers">
<TYPE>Ledger</TYPE>
<BELONGSTO>Yes</BELONGSTO>
<NATIVEMETHOD>Name</NATIVEMETHOD>
<FILTERS>Site</FILTERS>
</COLLECTION>
<SYSTEM TYPE="Formulae" NAME="Site">$Name = 'Site'</SYSTEM>
</TDLMESSAGE>
So, what it does is it checks if there is a ledger called 'Site'
This filter works perfectly. It only gives me one ledger whose name is 'Site'. But, what I need is a list of all the ledgers that contain the word 'Site' anywhere in their name.
Thus, I tried to use LIKE operator instead of =.
<SYSTEM TYPE="Formulae" NAME="Site">$Name LIKE 'Site'</SYSTEM>
答案1
得分: 1
"Like" 用于模式匹配,需要使用 "expression"。
如果您想使用字符串搜索,请使用 "Contains"。
<SYSTEM TYPE="Formulae" NAME="Site">$Name Contains 'Site'</SYSTEM>
英文:
Like is for pattern matching and it requires expression.
if you want to search with string use Contains
<SYSTEM TYPE="Formulae" NAME="Site">$Name Contains 'Site'</SYSTEM>
答案2
得分: 0
英文:
<ENVELOPE>
<HEADER>
<VERSION>1</VERSION>
<TALLYREQUEST>Export</TALLYREQUEST>
<TYPE>Collection</TYPE>
<ID>Ledgers</ID>
</HEADER>
<BODY>
<DESC>
<STATICVARIABLES>
<SVEXPORTFORMAT>SysName:XML</SVEXPORTFORMAT>
</STATICVARIABLES>
<TDL>
<TDLMESSAGE>
<COLLECTION ISMODIFY="No" ISFIXED="No" ISINITIALIZE="No" ISOPTION="No" ISINTERNAL="No" NAME="Ledgers">
<TYPE>Ledger</TYPE>
<BELONGSTO>Yes</BELONGSTO>
<NATIVEMETHOD>Name</NATIVEMETHOD>
<FILTERS>Site</FILTERS>
</COLLECTION>
<SYSTEM TYPE="Formulae" NAME="Site">$Name LIKE '%Site%'</SYSTEM>
</TDLMESSAGE>
</TDL>
</DESC>
</BODY>
</ENVELOPE>
This did the trick.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论