首页 > 解决方案 > 如何获取同级别的下一个直接xml节点

问题描述

我正在使用 ElementTree 在 python 中解析这个 XML 文件。

<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="
    http://www.springframework.org/schema/webflow
    http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">

<secured attributes="ROLE_USER" />

<input name="hotelId" required="true" />

<on-start>
    <evaluate expression="bookingService.createBooking(hotelId, currentUser.name)" result="flowScope.booking" />
</on-start>

<view-state id="enterBookingDetails" model="booking">
    <transition on="proceed" to="reviewBooking" />
    <transition on="cancel" to="bookingCancelled" bind="false" />
</view-state>

<view-state id="reviewBooking">
    <transition on="confirm" to="bookingConfirmed">
        <evaluate expression="bookingService.persistBooking(booking)" />
    </transition>
    <transition on="revise" to="enterBookingDetails" />
    <transition on="cancel" to="bookingCancelled" />
</view-state>

<end-state id="bookingConfirmed" />

<end-state id="bookingCancelled" />

</flow>

我需要紧邻节点的节点,但该节点必须是 Spring Webflow 状态节点,<on-start>即 a或等。如何使用 ElementTree 执行此操作?<view-state><action-state><decision-state>

标签: pythonxmlelementtree

解决方案


推荐阅读