如何使用XSLT从XML中删除子字符串

时间:2016-07-27 21:22:22

标签: xml xslt

我是XSLT的新手。我有一个XML文件,它有许多标记值

<submitTime>2016-06-09T18:27:56+0000</submitTime>
<submitTime>2016-06-09T18:13:10+0000</submitTime>
.......

我想将此 submitTime 日期格式转换为此格式(YYYY-MM-DD):

<submitTime>2016-06-09</submitTime>

如何从日期格式中删除时间?任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:2)

由于private static SearchResult NetSuiteSearchOrderItems(NetSuiteService netSuiteService, string order_name, string order_internalId) { CustomRecordSearch searchParts = new CustomRecordSearch(); CustomRecordSearchBasic basicRecordSearchParts = new CustomRecordSearchBasic(); basicRecordSearchParts.recType = new RecordRef { internalId = "64" }; //"Order Item" NetSuite Type ID //adding a search filter on a String Custom Field SearchStringCustomField partTypeFieldSearch = new SearchStringCustomField(); partTypeFieldSearch.@operator = SearchStringFieldOperator.@is; partTypeFieldSearch.internalId = "896"; //ID of the Part object's "Type" field partTypeFieldSearch.operatorSpecified = true; partTypeFieldSearch.searchValue = "Inventory Item"; //only want inventory item parts //Show me only parts on a certain Order CustomSearchJoin orderSearchJoin = new CustomSearchJoin(); CustomRecordSearchBasic orderBasicSearch = new CustomRecordSearchBasic(); orderBasicSearch.recType = new RecordRef { internalId = "56" }; //"Order" NetSuite Type ID //-- WHAT GOES HERE INSTEAD OF SearchStringCustomField? //adding a search filter on a String Custom Field SearchStringCustomField fsoItemTypeSearch = new SearchStringCustomField(); fsoItemTypeSearch.@operator = SearchStringFieldOperator.@is; fsoItemTypeSearch.internalId = "name"; //I have the "name" and numeric "internal id" of the order available. fsoItemTypeSearch.operatorSpecified = true; fsoItemTypeSearch.searchValue = order_name;//search filter value orderSearchJoin.searchRecordBasic = orderBasicSearch; //add in the things we want to search on basicRecordSearchParts.customFieldList = new SearchCustomField[] { partTypeFieldSearch }; //add the basic search and join search and then perform the search searchParts.basic = basicRecordSearchParts; searchParts.customSearchJoin = new CustomSearchJoin[] { orderSearchJoin }; SearchResult response = netSuiteService.search(searchParts); return response; } 值非常一致,您只需使用substring-before() ...

即可
submitTime

注意:以上<xsl:value-of select="substring-before(.,'T')"/> 假定上下文为xsl:value-of