我从Hyperion Planning系统中导出了所有的网络表单,我试图建立一个数据库,列出每个网络表单的关键细节。 webform将导出为XML,如下所示:
<?xml version="1.0" encoding="UTF-8" ?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="6.4 AC Planning" dir="Forms/PnL Inputs" enableOffline="false" planType="2" hide="false" enableCubeView="false" readOnly="false" >
<instruction>Use this form to view detailed account information, and input base level adjustments.</instruction>
<query>
<columns width="100" >
<segment>
<dimension displayName="true" displayAlias="false" displayMemberFormula="false" displayConsolidationOperators="false" name="Period" hide="false" expand="true" >
<function include="true" name="Descendants" >
<member name="YearTotal" />
</function>
</dimension>
</segment>
</columns>
<rows height="22" >
<segment readOnly="true" >
<dimension displayName="false" displayAlias="true" displayMemberFormula="false" displayConsolidationOperators="false" name="Account" hide="false" expand="true" >
<member name="Advertising - % of Net Revenue SP" />
</dimension>
</segment>
<segment showSeparator="true" >
<dimension displayName="false" displayAlias="true" displayMemberFormula="false" displayConsolidationOperators="false" name="Account" hide="false" expand="true" >
<member name="PL214040" />
<member name="PL214096" />
<member name="PL214011_01" />
<member name="PL214011_03" />
<member name="PL214011_02" />
</dimension>
</segment>
<segment>
<dimension displayName="false" displayAlias="true" displayMemberFormula="false" displayConsolidationOperators="false" name="Account" hide="false" expand="true" >
<member name="PL214021_01" />
<member name="PL214021_03" />
<member name="PL214021_02" />
<member name="PL214020" />
</dimension>
</segment>
</rows>
<pages>
<segment>
<dimension displayName="false" displayAlias="true" displayMemberFormula="false" displayConsolidationOperators="false" name="Entity" hide="false" >
<function include="true" name="Descendants" >
<member name="&Root_Entity" />
</function>
</dimension>
<dimension displayName="false" displayAlias="true" displayMemberFormula="false" displayConsolidationOperators="false" name="Product" hide="false" >
<function include="true" name="Descendants" >
<member name="&Root_Product" />
</function>
</dimension>
<dimension displayName="false" displayAlias="true" displayMemberFormula="false" displayConsolidationOperators="false" name="Channel" hide="false" >
<member name="CH02" />
<member name="CH03" />
</dimension>
<dimension displayName="false" displayAlias="false" displayMemberFormula="false" displayConsolidationOperators="false" name="Scenario" hide="false" >
<function name="Descendants" >
<member name="Planning Scenarios" />
</function>
</dimension>
<dimension displayName="false" displayAlias="false" displayMemberFormula="false" displayConsolidationOperators="false" name="Version" hide="false" >
<function name="Descendants" >
<member name="Planning Versions" />
</function>
</dimension>
<dimension displayName="false" displayAlias="false" displayMemberFormula="false" displayConsolidationOperators="false" name="Year" hide="false" >
<member name="&CurrFormYear1" />
<member name="&CurrFormYear2" />
</dimension>
<dimension displayName="false" displayAlias="false" displayMemberFormula="false" displayConsolidationOperators="false" name="Currency" hide="false" >
<member name="LCL" />
<member name="LCL (000s)" />
</dimension>
</segment>
</pages>
<pov>
<dimension displayName="false" displayAlias="false" displayMemberFormula="false" displayConsolidationOperators="false" name="EVA" hide="false" >
<member name="No_EVA" visible="true" />
</dimension>
<dimension displayName="false" displayAlias="false" displayMemberFormula="false" displayConsolidationOperators="false" name="ICP" hide="false" >
<member name="ZERO_ICP" visible="true" />
</dimension>
<dimension displayName="false" displayAlias="false" displayMemberFormula="false" displayConsolidationOperators="false" name="RptLevel" hide="false" >
<member name="RL0045" visible="true" />
</dimension>
</pov>
</query>
<businessRules>
<businessRule calcType="0" name="AandC_Base" planType="2" runOnSave="true" hidePrompt="true" useMRU="true" />
</businessRules>
<displayOptions>
<precision useCurrencyPrecision="false" nonCurrencyMax="0" nonCurrencyMin="0" currencyMax="2" percentageMax="2" currencyMin="0" percentageMin="0" />
<display poundMissing="true" enableAttributeDisplay="false" enableCellAttach="true" enableAdHoc="false" multiCurrency="false" enableMassAllocation="false" accountAnnotation="false" enableGridSpread="true" />
<printOptions>
<pageSettings pageSize="A4" orientation="0" font="" fontSize="8" rowHeaderPercentage="35" numDataCols="10" />
<format supportingDetails="false" applyPrecision="false" repeatHeaders="true" formatData="true" />
<printDisplay currency="true" shading="true" cellNotes="false" attribute="true" accountAnnotation="true" />
</printOptions>
<smartViewOptions enableForSmartSlice="false" enableOfflineUsage="false" />
</displayOptions>
<dataValidationRules>
<dataValidationRulesOptions>
<RunValidationsAsLoggedInUser>false</RunValidationsAsLoggedInUser>
<ValidateOnlyForPagesWithBlocks>false</ValidateOnlyForPagesWithBlocks>
<ValidateOnlyForUsersWithAccessToForm>false</ValidateOnlyForUsersWithAccessToForm>
</dataValidationRulesOptions>
</dataValidationRules>
</form>
因此,我希望从这样的内容构建:
Dimension | Location | Display name | Display alias | Members
______________________________________________________________________
Account | Row | False | True | PL214040; PL214096; PL214011_01; etc
Period | Column | True | False | Descendants(YearTotal)
我使用vbscript并尝试使用RegEx搜索来解决它,但虽然它们在大多数细节上工作正常,但是成员列表。
当我切换到XMLDOM时,但我无法取得成功。我在这里研究了很多,发现了很多很好的材料,但我无法采用它们来实现上述目标。
请记住,有些表单会在列中有帐号,有些表单会在pov中等等。我有一个可能的维度列表,所以我知道要查找什么,但其他所有内容都不同于一个XML到下一个。
任何帮助将不胜感激!
过了一会儿: 根据一些评论(谢谢!)以及更多使用XMLDOM的烦恼,我终于能够检索出我想要的最终结果的前3列,现在我只是#34;而且#34;无法找出每个维度中包含的所有成员。
下面是代码,我希望这进一步澄清了我的查询,并且有人将能够帮助我们如何收集成员以及每个维度的使用函数。
Set xmlDoc=CreateObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load("c:\Users\maxlamer\Documents\6.4 AC Planning.xml")
arrMyDimensions=Array("Account","Period","Currency/Value","Year","Entity","Scenario","ICP","Channel","Version","RptLevel","EVA","Product")
Set nodes = xmlDoc.selectNodes("//*")
For i = 0 to nodes.length - 1
bolFoundOne = False
m=0
For n=LBound(arrMyDimensions) to UBound(arrMyDimensions)
If nodes(i).getAttribute("name")=arrMyDimensions(n) Then
bolFoundOne = True
m=n
End if
Next
If bolFoundOne Then
If nodes(i).parentNode.nodeName="pov" Then
WScript.Echo arrMyDimensions(m) & " is in:" & nodes(i).parentNode.nodeName
Else
WScript.Echo arrMyDimensions(m) & " is in:" & nodes(i).parentNode.parentNode.nodeName
End if
Set pn_attribs = nodes(i).attributes
strMyTempString = arrMyDimensions(m) & " attributes :"
For Each pnAttr in pn_attribs
strMyTempString = strMyTempString & pnAttr.name & " = " & pnAttr.value & vbTab
Next
WScript.Echo strMyTempString & vbCrlf
arrMyDimensions(m)="XX_Located_XX"
End if
Next
我知道上面的内容相当粗糙,我仍然需要构建一个合适的包装器来使输出格式化得很好,但是应该让你很清楚我在驾驶什么。现在我只需要最后一栏。