Xml Element swaping

I am not getting how to swap two child xml elements in their parent xml element, Please help me.

  Thanks in advance ....................

Not sure I understand your question correctly but maybe this is what you’re looking for:

  XmlElement* a = xml1.getChildElement(index_a);
  XmlElement* b = xml2.getChildElement(index_b);

  xml1.removeChildElement(a, false); // remove a from xml1 but don't delete a

  xml2.removeChildElement(b, false); // remove b from xml2 but don'e delete b


XmlElement has value semantics, so:

Thank you jules, i will try this one

hi jules, i tried swapping with std::swap.
But it is crashing, because for some iteration i am getting one of those child element null, i have pasted my piece of code.

Here pCellContainer is the parent xml and i have vector of pair, which is indices.

        std::vector<std::pair<int, int> > vecMovedItems ;
        for(int i = 0; i < vecMovedItems.size(); i++)
            int iOldIndex = vecMovedItems[i].second  ;
            int iNewIndex = vecMovedItems[i].first ;
            juce::XmlElement* pOldCellElement = pCellContainer->getChildElement(iOldIndex) ;
            juce::XmlElement* pNewCellElement = pCellContainer->getChildElement(iNewIndex) ; 
            std::swap(*pOldCellElement, *pNewCellElement);

  please help .............thanks