本文介绍了数据处理,如何处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我给了这个XML数据结构有以下问题:

I have the following Problem, given this XML Datastructure:

<level1>
 <level2ElementTypeA></level2ElementTypeA>
 <level2ElementTypeB>
   <level3ElementTypeA>String1Ineed<level3ElementTypeB>
 </level2ElementTypeB>
 ...
 <level2ElementTypeC>
    <level3ElementTypeB attribute1>
      <level4ElementTypeA>String2Ineed<level4ElementTypeA>
    <level3ElementTypeB>
 <level2ElementTypeC>
 ...
<level2ElementTypeD></level2ElementTypeD>
</level1>
<level1>...</level1>

我需要创建一个包含String1Ineed和String2Ineed的实体。

I need to create an Entity which contain: String1Ineed and String2Ineed.

因此,每次遇到属性1中具有特定值的level3ElementTypeB时,我都有我的String2Ineed。丑陋的部分是如何获取String1Ineed,它位于当前level2ElementTypeC之上的level2ElementTypeB类型的第一个元素中。

So every time I came across a level3ElementTypeB with a certain value in attribute1, I have my String2Ineed. The ugly part is how to obtain String1Ineed, which is located in the first element of type level2ElementTypeB above the current level2ElementTypeC.

我的'命令式'解决方案看起来像我总是用String1Ineed的最后一个值保留一个变量,如果我击中了String2Ineed的条件,我就简单地使用它。如果我们从简单的收集处理角度来看这个问题。你将如何建模String1Ineed和String2Ineed之间的回溯逻辑?使用State Monad?

My 'imperative' solution looks like that that I always keep an variable with the last value of String1Ineed and if I hit criteria for String2Ineed, I simply use that. If we look at this from a plain collection processing point of view. How would you model the backtracking logic between String1Ineed and String2Ineed? Using the State Monad?

推荐答案

XPATH的用途不是这样吗?您可以找到String2Ineed,然后更改轴以搜索String1Ineed。

Isn't this what XPATH is for? You can find String2Ineed and then change the axis to search back for String1Ineed.

这篇关于数据处理,如何处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-26 13:54