Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
338 views
in Technique[技术] by (71.8m points)

xml - How to add the node at the specific place of the Dictionary<XElement,XElement> in c#?

Dictionary

Dictionary<XElement, XElement> _XParents = new Dictionary<XElement, XElement>();

My dictionary looks like:(in general)

key:<node>, value: <parentnode>

in my case:

Key: <Branch1>
  <Child1 />
  <Child3 />
</Branch1>, Value: <Root>
  <Branch1>
    <Child1 />
    <Child3 />
  </Branch1>
  <Branch2 />
</Root>
Key: <Child1 />, Value: <Branch1>
  <Child1 />
  <Child3 />
</Branch1>
Key: <Child3 />, Value: <Branch1>
  <Child1 />
  <Child3 />
</Branch1>
Key: <Branch2 />, Value: <Root>
  <Branch1>
    <Child1 />
    <Child3 />
  </Branch1>
  <Branch2 />
</Root>

My XML looks like:

<Root>
    <Branch1>
        <Child1/>
        <Child2/>
    </Branch1>
    <Branch2>
</Root>

I have tried this, which is adding the node at the end but i do not know how to add it at the specific place:

abc = new XElement("Child3");
pqr = new XElement("Branch1", new XElement("Child1",),
                              new XElement("Child2"));

 _XParents.Add(abc,pqr);
question from:https://stackoverflow.com/questions/66052251/how-to-add-the-node-at-the-specific-place-of-the-dictionaryxelement-xelement-i

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...