adding nodes from xml

  • NewBdude

    NewBdude - 2011-06-30

    I am working on a project in which, we need to add nodes from xml file with <machine> and <service> tags. I am new to prefuse. please let me know how can I achieve this.

    Thanks a lot for the help and your time!

  • Björn Kruse

    Björn Kruse - 2011-06-30

    Do you mean initially adding the nodes or do you mean later adding nodes to an existing prefuse graph (both based on your xml format)?

    I think writing a XSL Stylesheet that transforms your xml to GraphML is the way to go. Prefuse contains classes that automatically read xml files that are in GraphML format.
    (Haven't done anything with prefuse for a long time now - I'm not sure if GraphMLReader is able to add items to an existing graph…)


  • NewBdude

    NewBdude - 2011-06-30

    Hi, I have my xml in GraphML formalt. I am using the SocialNet example for my project. In that example, it takes the <node> elements in the xml for add nodes in the graph. Now, I need to customize it so that I can add nodes from the <machine> and <service> tags.
    Is there any possible way to achieve this?

    Thank you!

  • Björn Kruse

    Björn Kruse - 2011-07-02

    Hi, I have my xml in GraphML formalt.

    Now, I need to customize it so that I can add nodes from the <machine> and <service> tags.

    If you have <machine> and <service> tags, than your xml is NOT in GraphML format.

    Maybe you can convert it to a format readable by GraphMLReader, for example like below. Either convert your existing xml or maybe you can tweak the source which generates your xml file.

    <node id="1">

    <data key="name">name_1</data>

    <data key="machine">m_1</data>

    <data key="serivce">s_1</data>

    <node id="2">
    <data key="name">name_2</data>
    <data key="machine">m_2</data>
    <data key="serivce">s_2</data>

    Otherwise, sorry, I didn't understand fully. Then please say why it doesn't work (errors?) for you and what you tried to resolve it.

    regards, Björn

  • NewBdude

    NewBdude - 2011-07-06

    Hi Björn,

    Thanks man! I had my xml restructured and now its working fine. :-) Also, while browsing through the docs, I found a Graph constructor with node schema and edge schema. How do I make my schemas for this to work?

    Thanks a lot for the help. Really appreciate it!


Log in to post a comment.