我有一个XML文件,结构如下:
<ns1:ReservationPCC pseudoCityCode="1234" pseudoCityType="Booking" supplierService="Sabre"/>
我想用abcd代替pseudoCityCode。
我正在尝试以下方法:
sed -e's/pseudoCityCode=.*/pseudoCityCode="abcd" /g'
但是,它返回:
<ns1:ReservationPCC pseudoCityCode="abcd"
添加空格:
sed -e's/pseudoCityCode=.*\s/pseudoCityCode="abcd" /g'
将返回以下内容:
<ns1:ReservationPCC pseudoCityCode="abcd" supplierService=Sabre/>
为什么pseudoCityType会消失?我错过了什么?
卡洛斯
答案 0 :(得分:2)
gremlin> graph = TinkerGraph.open()
==>tinkergraph[vertices:0 edges:0]
gremlin> g = graph.traversal()
==>graphtraversalsource[tinkergraph[vertices:0 edges:0], standard]
gremlin> g.addV("name", "i2").as("a").addV("name", "state1").addE("to").from("a").toList()
==>e[4][0-to->2]
gremlin> fromNode = g.V().has("name", "i2").next()
==>v[0]
gremlin> toNode = g.V().has("name", "state1").next()
==>v[2]
gremlin> l = new ArrayList()
gremlin> g.V(fromNode).repeat(both().simplePath()).until(is(toNode)).limit(1).path().fill(l)
==>[v[0],v[2]]
gremlin> l = []; g.V(fromNode).repeat(both().simplePath()).until(is(toNode)).limit(1).path().fill(l)
==>[v[0],v[2]]
gremlin> l = []; g.V(fromNode).repeat(both().simplePath()).until(is(toNode)).limit(1).path().unfold().fill(l)
==>v[0]
==>v[2]
gremlin> l[0].getClass()
==>class org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex
gremlin> l[0].property("name", "j3") // mutate the vertex's name
==>vp[name->i3]
gremlin> g.V(fromNode).valueMap(true).toList()
==>[id:0,name:[j3],label:vertex]
或者像@Ed Morton说的那样:
sed 's/pseudoCityCode="[^"]*"/pseudoCityCode="abcd"/'<<<'<ns1:ReservationPCC pseudoCityCode="1234" pseudoCityType="Booking" supplierService="Sabre"/>'