点击空白处退出提示
作品详情
代码示例:
use etree::*;
use std::path::Path;
fn modify_xml(path_in:P, path_out:P) {
let mut tree = ETree::parse_file(path_in);
let subtree_pos = tree.find("//CHILD-A").unwrap();
let mut subtree = tree.subtree(subtree_pos);
let subtree_child_pos = subtree.find("/SUBCHILD-A").unwrap();
if let Some(node) = subtree.node_mut(subtree_child_pos) {
node.set_text("WEST");
}
// tree.append_next_tree(subtree_pos, subtree.clone());
let parent_pos = tree.parent(subtree_pos).unwrap();
tree.append_child_tree(parent_pos, subtree);
tree.write_file(path_out).ok();
}
声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态
评论