java xml 获取节点属性名

在不确定属性名的时候怎么知道有哪些属性?

我翻了docs.oracle.com没看到有相关的方法。

举例xml

<agents>

  <denounce_inquisitor_base_chance float="35.0"/>
  <denounce_priest_base_chance float="33.0"/>
  <denounce_attack_modifier float="1.0"/>
  <denounce_defence_modifier float="1.0"/>
  <denounce_chance_min int="5"/>
  <denounce_chance_max int="95"/>
  <denounce_heretic_attemp_modifier float="1.5"/>
  <denounce_character_attemp_modifier float="0.5"/>
  <assassinate_base_chance float="33"/>
  <assassinate_attack_modifier float="0.5"/>
  <assassinate_defence_modifier float="0.5"/>
  <assassinate_public_modifier float="1.0"/>
  <assassinate_personal_modifier float="1.0"/>
  <assassinate_counter_spy_modifier float="1.0"/>
  <assassinate_agent_modifier float="4.0"/>
  <assassinate_own_region_modifier float="1.0"/>
  <assassinate_assassinate_attr_modifier float="0.33"/>
  <assassinate_chance_min int="5"/>
  <assassinate_chance_max int="95"/>
  <acquisition_base_chance float="40.0"/>
  <acquisition_level_modifier float="5.0"/>
  <acquisition_attack_trade_rights_modifier float="1.3"/>
  <acquisition_defence_trade_rights_modifier float="0.7"/>
  <acquisition_chance_min int="5"/>
  <acquisition_chance_max int="95"/>
  <inquisitor_crt_heresy_divisor float="1.0"/>
  <inquisitor_crt_pfp_modifier float="0.5"/>
  <inquisitor_crt_pfp_modifier_min float="0.0"/>
  <inquisitor_crt_pfp_modifier_max float="1.0"/>
  <inquisitor_crt_chance_min float="0.0"/>
  <inquisitor_crt_chance_max float="0.1"/>
  <spy_base_chance float="40.0"/>                  <!-- base spying chance -->
  <spy_level_modifier float="0.15"/>                <!-- modifies the amount the subterfuge rating of a spy affects chance of success

-->

  <not_spy_level_modifier float="0.5"/>            <!-- modifies the chance of success if spying object not a spy -->
  <spy_public_modifier float="1.0"/>               <!-- inversely modifies the amount the public security aspects of the target affects

chance of success -->

  <spy_counter_spy_modifier float="1.0"/>          <!-- inversely modifies the amount the combined subterfuge rating with the target

affects chance of success -->

  <spy_distance_modifier float="1.0"/>             <!-- inversely modifies the amount the distance in movement points from the target

affects chance of success -->

  <spy_secret_agent_target_modifier float="0.5"/>  <!-- modifies the chance of success if an assassin or spy is travelling with a

target army -->

  <spy_sedentary_turns_modifier float="0.2"/>      <!-- modifies the amount of turns a target has been stationary affects chance of

success -->

  <spy_alliance_modifier float="1.5"/>             <!-- modifies the chance of success if the target is allied with spy faction -->
  <spy_target_engaged_modifier float="2.0"/>       <!-- modifies the chance of success if target is in engagement, under siege or

battle -->

  <spy_in_settlement_modifier float="5.0"/>        <!-- modifies the chance of success if spy in settlement they are spying on -->
  <spy_watchtower_modifier float="2.5"/>           <!-- modifies the chance of success if spying object is a watchtower -->
  <spy_in_own_region_modifier float="1.2"/>        <!-- modifies the chance of success if spy in in their own factions region -->
  <spy_chance_min int="5"/>                        <!-- min clamp for spy chance -->
  <spy_chance_max int="95"/>                       <!-- max clamp for spy chance -->
  <spy_rescale_chance bool="false"/>               <!-- flag to indicate if the final chance is non-linearly rescaled to improve

spying chance of success --> </agents>

当然这里还可以枚举属性名,但是总觉得累赘。

有什么方法能够获得属性名?

谢谢

阅读 1.8k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题