Hi all,

how can i move Xml content?

Here is my xml document sample.

<content>
   <Media>
      <Title>Mov1</Title>
      <MediaType>DVD</MediaType>
   </Media>
   <Media>
      <Title>Mov2</Title>
      <MediaType>DVD</MediaType>
   </Media>
   <Media>
      <Title>Mov3</Title>
      <MediaType>DVD</MediaType>
   </Media>
   <Media>
      <Title>Mov4</Title>
      <MediaType>DVD</MediaType>
   </Media>
</content>

The challenge is to move the "Media" Tag with Title Mov4 to position one!

Looks like this:

<content>
   <Media>
      <Title>Mov4</Title>
      <MediaType>DVD</MediaType>
   </Media>
   <Media>
      <Title>Mov1</Title>
      <MediaType>DVD</MediaType>
   </Media>
   <Media>
      <Title>Mov2</Title>
      <MediaType>DVD</MediaType>
   </Media>
   <Media>
      <Title>Mov3</Title>
      <MediaType>DVD</MediaType>
   </Media>
</content>

How can i do this?

The following doesn't work :(

XmlCursor sourceCursor = xml.newCursor();
searchPath = "Media[Title='Mov4']";
sourceCursor.selectPath(searchPath);

XmlCursor targetCursor = xml.newCursor();
searchPath = "Media[Title='Mov1']";
targetCursor.selectPath(searchPath);

sourceCursor.moveXmlContents(targetCursor) ---> Error: Can't insert before the start of the document. sourceCursorCursor.moveXml(targetCursor) ---> Error: Can't move/copy/insert a whole document.

I hope someone can help me.

Thanks in advance.

Christian


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to