Referencing a particular block when building xml

AvengedAbigail

New Member
I'm using Ruby to build gexf-formatted XML structure that would represent a network graph. The graph consists of of several levels of nested nodes. The idea is to parse a file that looks something like this:\[code\]| top node | middle node | bottom node || a | 1 | "name1" || b | 1 | "name6" || a | 2 | "name3" || b | 2 | "name8" || b | 1 | "name5" || a | 1 | "name2" || b | 2 | "name7" || a | 2 | "name4" |\[/code\]and transform it into this:\[code\]<node id = a label = "top node"> <node id = 1 label = "middle node"> <node id = name1 label = "bottom node"/> <node id = name2 label = "bottom node"/> </node> <node id = 2 label = "middle node"> <node id = name3 label = "bottom node"/> <node id = name4 label = "bottom node"/> </node> </node><node id = b label = "top node"> <node id = 1 label = "middle node"> <node id = name5 label = "bottom node"/> <node id = name6 label = "bottom node"/> </node> <node id = 2 label = "middle node"> <node id = name7 label = "bottom node"/> <node id = name8 label = "bottom node"/> </node> </node>\[/code\]As you can see, since the lines in the file are not in any particular order, I need to be able to reference each node and sub-node when building the XML file.In case my question is still not clear, when I read the line:\[code\]| b | 1 | "name6" |\[/code\]I need to be able to tell the builder to stick this node "name6" inside "top node b" and "middle node 1". Is it at all possible with Builder or Nokogiri's builder or anything else out there?
 
Back
Top