Uploaded image for project: 'Forge'
  1. Forge
  2. FORGE-2293

Forge XML parser - Add api so you can insert a child node at a given index

    XMLWordPrintable

Details

    • Feature Request
    • Resolution: Duplicate
    • Major
    • None
    • 2.15.2.Final
    • None

    Description

      I am using the nice XMLParser API from
      https://github.com/forge/xml-parser

      But having a Node, I need to add a new child node at a specific order. Today the child node is added at the end. But my XSD has a structure so I must add the child node at a given position.

      I cannot find an api to do that. I may have to remove all child nodes, and rebuild the structure in the order I need. But I think that is a bit drastic - would be nice if there was an api to do that.

      For example a addSibling method that creates a sibling node, and inserts it just after current node, eg

      If the children is

      A,B,C,D,E,F

      And then I want to add a C2, I can do

      Node c = ...
      c.addSibling("C2);

      And then we have
      A,B,C,C2,D,E

      Node camel = ...
      for (Node child : camel.getChildren()) {
          ...
          logic here
          if (yeah) {
            Node newEndpoint = child.addSibiling("endpoint);
            newEndpoint.attribute("id", "foo");
            newEndpoint.attribute("url", "bla bla");
          }
      }
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              cibsen@redhat.com Claus Ibsen
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: