Info

This question is closed. Reopen it to edit or answer.

scan txt file and change related information

1 view (last 30 days)
Kyle
Kyle on 8 Nov 2012
Closed: MATLAB Answer Bot on 20 Aug 2021
Hi, experts
I have a txt file, in which there are some information I want to adjust with efficiency. The txt file is actually generated by social network software: yEd - Graph Editor
the txt file structure is as below (a part of the txt file):
<node id="n0">
<data key="d4"><![CDATA[2.0]]></data>
<data key="d7">
<y:Geometry height="36.0" width="36.0" x="350.0" y="1550.1944444444443"/>
<y:Fill color="#FFFFFF" transparent="false"/>
<y:BorderStyle color="#000000" type="line" width="1.0"/>
<y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.1328125" modelName="internal" modelPosition="c" textColor="#000000" visible="true" width="22.97265625" x="6.513671875" y="8.93359375">2.0</y:NodeLabel>
<y:Shape type="ellipse"/>
</data>
</node>
<node id="n1">
<data key="d4"><![CDATA[4.0]]></data>
<data key="d7">
<y:Geometry height="36.0" width="36.0" x="2299.1944444444443" y="127.0"/>
<y:Fill color="#FFFFFF" transparent="false"/>
<y:BorderStyle color="#000000" type="line" width="1.0"/>
<y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.1328125" modelName="internal" modelPosition="c" textColor="#000000" visible="true" width="22.97265625" x="6.513671875" y="8.93359375">4.0</y:NodeLabel>
<y:Shape type="ellipse"/>
</data>
</node>
It's with common sense social network plot is actually connecting nodes by graphic theory. Codes above describes the properties of two nodes, with each node defined within
<node id="n0">
...
</node>
It's the first node. then the second one is
<node id="n1">
...
</node>
using the first node as an example, the second line
key="d4"<![CDATA[2.0]]></data>
indicates the node ID, here is 2.0, the number after "CDATA". One node property is the fill color
#FFFFFF indicates the colour.
The other property is the node shape:
"ellipse" is the shape.
So #FFFFFF and ellipse can be changed to another color and something like 'rectangle' or 'round'.
Now here is my question: this txt file is actually quite long, containing lots of nodes information, and notice that these nodes ID are not put in sequence. I have a list of IDs of nodes of my particular interests, I want to change "color" and "shape" information for those nodes. So, how can I setup an algorithm to locate "color" and "shape" of a particular node based on its ID, and change the "color" and "shape" to a value.
Many thanks for any help!!

Answers (0)

This question is closed.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!