2
Answers

Manipulating XML with LinQ

JeanNicolas

JeanNicolas

14y
3.4k
1
Hi everybody,

I need some help regarding inserting node on an xml.

I have a xml tree and I want to insert data on a specific location on the tree.

Joining an example. How do I do, if I want to insert a node between Hierarchy with ID_Hierarchy="5" and Hierarchy ID_Hierarchy="6".

    <Hierarchy ID_Hierarchy="3" ID_Level="2">
      <Text_ref>333</Text_ref>
      <Parent>1</Parent>
      <Previous>2</Previous>
      <Next>4</Next>
      <HasChild>true</HasChild>
      <Active>true</Active>
      <Hierarchy ID_Hierarchy="5" ID_Level="3">
        <Text_ref>555</Text_ref>
        <Parent>3</Parent>
        <Previous>0</Previous>
        <Next>6</Next>
        <HasChild>false</HasChild>
        <Active>true</Active>
      </Hierarchy>
      <Hierarchy ID_Hierarchy="6" ID_Level="3">
        <Text_ref>666</Text_ref>
        <Parent>3</Parent>
        <Previous>5</Previous>
        <Next>0</Next>
        <HasChild>false</HasChild>
        <Active>true</Active>
      </Hierarchy>
    </Hierarchy>
    <Hierarchy ID_Hierarchy="4" ID_Level="2">
      <Text_ref>444</Text_ref>
      <Parent>1</Parent>
      <Previous>3</Previous>
      <Next>0</Next>
      <HasChild>false</HasChild>
      <Active>true</Active>
    </Hierarchy>
  </Hierarchy>

The best solution I can think is to reconstruct the entire node but maybee is there a better solution.

Thanks for the assistance.

Answers (2)