Add multiple nodes of the same name from one xml into another

Hello

Following my question the other day (adding several nodes of different one xmltype in the other), I now need a bit more complex that I can't work on where to begin, assuming that it is something that can reuse some/all the quote from yesterday (thank you once again, odie_63!). ETA: I'm on 11.2.0.3

So, here's the (slightly modified) xml with the solution of yesterday:

with sample_data as (select xmltype ("< root >

< xmlnode >

val1 < subnode1 > < / subnode1 >

val2 < subnode2 > < / subnode2 >

< / xmlnode >

< xmlnode >

val3 < subnode1 > < / subnode1 >

< subnode2 > val4 < / subnode2 >

< / xmlnode >

< / root >') xml_to_update,.

XmlType ("< a >

< b > < /b > valb

valc < c >/< c >

< d >

vald1 < d1 > < / d1 >

< d2 > vald2 < / d2 >

/ < d: >

Vale of < e > < /e >

valf < f > < /f >

< g >

valg1 < g1 > < / g1 >

valg2 < g2 > < / g2 >

/ < g >

< h >

valh1 < h1 > < / h1 >

valh2 < h2 > < / h2 >

< HR >

< volume >

< name > fred < / name >

< type > book < / type >

Head of <>1 < / head >

< / multi-user >

< volume >

Bob < name > < / name >

car of < type > < / type >

< head > 0 < / head >

< / multi-user >

( < /a >') xml_to_extract_from

the double)

Select xmlserialize (document

XMLQUERY)

' copy $d: = $old

Edit)

Insert the node element extrainfo {}

$ new/a/b

, $ new/a.

, $ new/e/f

, $/ a/h new

} as the first in $d / root

)

return $from

by passing sd.xml_to_update as "old."

, sd.xml_to_extract_from as 'new '.

contents of return

)

dash

)

of sample_data sd;

It gives me:

< root >

< InfosSuppl >

< b > < /b > valb

< d >

vald1 < d1 > < / d1 >

< d2 > vald2 < / d2 >

/ < d: >

valf < f > < /f >

< h >

valh1 < h1 > < / h1 >

valh2 < h2 > < / h2 >

< HR >

< / extrainfo >

< xmlnode >

val1 < subnode1 > < / subnode1 >

val2 < subnode2 > < / subnode2 >

< / xmlnode >

< xmlnode >

val3 < subnode1 > < / subnode1 >

< subnode2 > val4 < / subnode2 >

< / xmlnode >

< / root >

However, I now need to add new nodes according to the information provided by the < volume > something like nodes in a set:

< root >

< InfosSuppl >

< b > < /b > valb

< d >

vald1 < d1 > < / d1 >

< d2 > vald2 < / d2 >

/ < d: >

valf < f > < /f >

< h >

valh1 < h1 > < / h1 >

valh2 < h2 > < / h2 >

< HR >

< newnode >

< name > fred < / name >

< type > book < / type >

< / newnode >

< newnode >

< name > bob < / name >

car of < type > < / type >

< / newnode >

< / extrainfo >

< xmlnode >

val1 < subnode1 > < / subnode1 >

val2 < subnode2 > < / subnode2 >

< type > book < / type >

< / xmlnode >

< xmlnode >

val3 < subnode1 > < / subnode1 >

< subnode2 > val4 < / subnode2 >

car of < type > < / type >

< / xmlnode >

< / root >

If it's easier, I * think * we would be ok with something like:

...

< newnode >

< name type = 'fred' > book < / type >

car < name type = 'bob' > < / type >

< / newnode >

...

Is the closest, I came:

with sample_data as (select xmltype ("< root >

< xmlnode >

val1 < subnode1 > < / subnode1 >

val2 < subnode2 > < / subnode2 >

< / xmlnode >

< xmlnode >

val3 < subnode1 > < / subnode1 >

< subnode2 > val4 < / subnode2 >

< / xmlnode >

(< / root > ') xml_to_update,.

XmlType ("< a >

< b > < /b > valb

valc < c >/< c >

< d >

vald1 < d1 > < / d1 >

< d2 > vald2 < / d2 >

/ < d: >

Vale of < e > < /e >

valf < f > < /f >

< g >

valg1 < g1 > < / g1 >

valg2 < g2 > < / g2 >

/ < g >

< h >

valh1 < h1 > < / h1 >

valh2 < h2 > < / h2 >

< HR >

< volume >

< name > fred < / name >

< type > book < / type >

Head of <>1 < / head >

< / multi-user >

< volume >

Bob < name > < / name >

car of < type > < / type >

< head > 0 < / head >

< / multi-user >

(< /a > ') xml_to_extract_from

the double)

Select xmlserialize (document

XMLQUERY)

' copy $d: = $old

Edit)

Insert the node element extrainfo {}

$ new/a/b

, $ new/a.

, $ new/e/f

, $/ a/h new

newnode}

$ new/a/multi-user/name

, $/ a/multi-user/new

}

} as the first in $d / root

)

return $from

by passing sd.xml_to_update as "old."

, sd.xml_to_extract_from as 'new '.

contents of return

)

dash

) fred

of sample_data sd;

Which produces:

...

< newnode >

< name > fred < / name >

Bob < name > < / name >

< type > book < / type >

car of < type > < / type >

< / newnode >

...

-obviously not right!

Can anyone give advice? I tried to find similar examples, but I can't put it in the right search terms, or something!

Hello

To manage the expandable nodes, you have to iterate using a FLWOR expression:

copy $d: = $old

Edit)

Insert the node element extrainfo {}

$ new/a/b

, $ new/a.

, $ new/e/f

, $/ a/h new

, for $i in $ a/new/multi-user

will return the newnode item {$i / name, $i / type}

} as the first in $d / root

)

return $d

or, even, to get the result by replacing:

copy $d: = $old

Edit)

Insert the node element extrainfo {}

$ new/a/b

, $ new/a.

, $ new/e/f

, $/ a/h new

newnode}

for $i in $ a/new/multi-user

Returns the element type {}

name of the attribute {data($i/name)}

data($i/type)

}

}

} as the first in $d / root

)

return $d

Tags: Database

Similar Questions

  • Transfer documents, photos, movies and music on the same laptop from one session to another.

    I have a Mac Book Pro OSX El Capitan.

    I transferred everything from my administrator of my iMac to my Mac Book Pro.

    I know how to create a session, or delete, but I can't find how to transfer files from one session to the next to keep only one.

    Maybe there is no way, and I have to do it manually with a USB key.

    If anyone can help me with this, I would be grateful.

    Sorry for my English is not too good. I'm french and I is the first time that I post a message!

    Thank you

    Hi Appia,

    Thank you for using communities Support from Apple! I'm sorry to hear that you are having these problems with your iMac and your MacBook Pro. I'm a bit ambiguous on the specific issue you describe, but if you speak to migrate your user accounts or data from an older Mac to a new Mac, you can find information and the steps described in the following articles useful:

    Move your content to a new Mac - Apple Support

    OS X: manually the Data Migration from another Mac - Apple Support

    Concerning

  • How to move the virtual machine from one cluster to another cluster

    How to move the virtual machine from one cluster to another cluster

    If two Clusters are in the same data center, you could do a 'live' migration or vMotion, if that's the case.   If the virtual machine is turned off, it may be migrated regardless of the data center.

  • How to change the Web server from one server to another server

    Hi all

    Can you please provide the document to change the location of the web server from one server to another server?

    Thanks in advance.

    Thank you and best regards,
    Siva Prasad B

    Siva Prasad says:
    Hi Michel,.

    Coping PS_HOME just move the web server?

    And Michel and I said earlier that you need to reinstall your Web server... and to redeploy the PIA, which is not clear?

    Nicolas.

  • [.ini files] Get the value of multiple labels with the same name

    Hello!

    In an ini.files, I need to get the value of each tag named in a certain way in a section, but unfortunately, I have 3 or 4 tags with the same name in several sections. I don't know how to retrieve these values, the program always consider that the first tag and not others, I tried to remove each tag after obtaining its values, that he did not.

    Does anyone have an idea to solve the problem?

    Thank you!

    As you can read in my last post, you must read and throw 'x' lines:

    OpenFile)

    Skip lines

    for (i = 0; i< x;="" i++)="" readline="">

    Start reading the useful lines

    ReadLine () / / read a line

    ... / / Interpret the line

    Don't forget to add a control during i/o operations of robust error and to check the end of the file.

  • How to open multiple files with the same extension in one program from the Explorer

    I frequently receive several JPG (or whatever extension) files to my clients.  On Windows XP, I could just highlight the files I want to open, and then click Open.  They would be so open to 1 program cascading.  This made it easy when comparing many images.  If I do the same thing in Windows 7, it opens the default program several times and puts 1 image of each open program.  It is Paint Shop Pro in my case.  Thus, instead of so-called images 5 open cascading in Paint Shop Pro... the computer open Paint Shop Pro 5 times with 1 image of each open version of the program.  I tried this search like crazy, but cannot find the right thread for an answer.  Most of the threads are on the opening of the different file types.  My question is only about the opening of multiple files with the same exact file inside 1 free program extension.

    Is this the same version of Paint Shop?

    One thing you might try is to open Paint Shop, then select and drag all the files in this window of the paint shop.  Various programs to manage this type of action differently from the DDE, but it might give you the expected results.

  • How to name multiple files with the same name?

    HI, I'm supposed to write the names of files for an agency and I noticed that all the photographers name the files of the same Gallery of the same name, I guess it's renaming the bridge batch? TXS

    Yes, use the bridge to rename lots. I would recommend using the text that you want (add a _ at the end) and then add a number to four digits of the sequence.

    Here is a little video I did for someone else last night. You can find it useful, too:

  • How to register multiple files with the same name with different num revision

    Hello

    Can someone please tell me, how to register several different files with the same name with the revision number using the RIDC API.

    For example:
    First of all I will be saved in a file (TestFile.txt) in a content server with revision number 1 using the RIDC API in application of the ADF. Then after awhile, will change the same line (TestFile.txt) check-in and once again. I tried to check the same file several times, however first Check-in correctly in server showing revision 1, so that Check-in same file again, her gives no error message, and also its not reflecting only not to the server. Single file (TestFile.txt) reflecting on the server.

    How to implement this feature using the RIDC API? Any suggestions would be helpful.

    Concerning
    REDA

    Published by: 887680 on March 6, 2013 10:48

    (1) get the content ID (dDocName), call CHECKOUT_BY_NAME
    (2) call check-in service with dRevLabel = previous dRevlabel + 1

  • Moving the ASM LUNS from one server to another

    Hi all

    I have ASM 11.2.0.2 on Oracle Enterprise Linux server connected to an IBM DS5100. On a single server, I have a database I want to move to another physical server. It is possible to detach the LUNS from the source server and connect to the new server, and then restart the database, providing I have copy all relevant configurations on the new server? Kinda like the old exportvg/importvg, we in the Unix world. I searched the web but can't find a method to achieve this or if it is still possible. Any help will be greatly appreciated.

    Gary

    Source server:

    1.) NO.! Because if you drop the diskgroup ASM header gets erased, and the other system won't be able to detect
    2.) NO.! Both dynamically find the disks. If they are simply not there... so they be found. So no information on diskgroup etc.
    The only thing that you should probably take care is to remove the name diskgroup asm_diskgroup parameter form. Otherwise ASM will say that it does not find the diskgroup during startup.
    3.) anyone simply it. Then multipath not detect either...

    Target server:
    1.) Yes. However, you must keep the file multipath.conf for the entries of the same as on the other server, that devices receive the same names. Otherwise the names will be different, which is not nice, but not a problem.
    2.) simply SCAN the discs, and they should be disclosed. Make sure that your SCAN_ORDER and SCAN_EXCLUDE parameters are o.k. for asmlib.
    Yes 3). Simply mount.

    Concerning
    Sebastian

  • My IPAD seems to go on auto-pilot: How can I stop the he flicking from one thing to another?

    How can I stop my IPAD II of flicking from one thing to another without my intervention?

    You probably have a defective scanner on the screen and so will have to do to fix it.

    iPad repair - official Apple Support

  • move the SSL Cert from one device to another on Cisco ASA

    Hi all

    Is it possible to have a certificate SSL + key of a cisco asa to another? I hope its possible and if anyone can guide me to fix the documentation that would be perfect.

    Thank you

    Manish

    Hello

    This document will do it for you

    http://www.Cisco.com/en/us/products/ps6120/products_configuration_example09186a00809fcf91.shtml#copycert

    Check the How to copy one ASA to another SSL certificates

    Kind regards

    Any other questions... Sure... Be sure to note all my answers.

  • Windows 8 store listing Multiple PCs with the same name - how to remove?

    Hi there... when I go to the store in Windows 8, in my account settings, I see four listed computers.  Two of them are named similarly (I reinstalled Windows 8 a few weeks after I had first and kept my the same PC name).

    I would like to remove one of the PC that has a duplicate name, but I don't know that one to remove.  Y at - it an easy way to see what is the PC I'm on right now, and what is the old PC?  I'm paranoid that to remove that incorrect it will cause my apps on this PC to stop working.

    Thank you!

    In fact, I just understand how do.  Here's what worked for me:

    • Rename your computer from the desktop.  Right click on my computer > properties > etc.
    • You will need to reboot for the change to take effect.
    • Now, go to the Windows store and download an application.  Any application.  It may be a free, or one that you have already purchased.  Is not serious.
    • Once the download is complete, you can return to your account in Store, and you'll see your list of computers is updated with your newly renamed computer.
    • You can now delete the duplicate computer registration.
    • Once it is removed, follow the steps above to rename your computer in its original name.

    It seems that you must actively download an app from the store in order to force it to update the list of the PCs in your bank account settings.

  • How to add multiple tabStops at the same time...

    Hello

    I know it's a bit basic, but I fight

    I am trying to create four tabStops in a paragraph style. That's what I have so far... but when it comes to tabStops [1], he died... I think that something is wrong with how I create the four tabStops, but I do not know what... Do you think what I am doing wrong?

    Thank you!
    Christopher

    try {}

    myParagraphStyle = myDocument.paragraphStyles.item ("Verse");

    myName = myParagraphStyle.name;

    }

    {} catch (e)

    myParagraphStyle = myDocument.paragraphStyles.add({name:"Verse"});)

    myParagraphStyle.tabStops.add ();

    myParagraphStyle.tabStops.add ();

    myParagraphStyle.tabStops.add ();

    myParagraphStyle.tabStops.add ();

    with (myParagraphStyle) {}

    appliedFont = "Lexicon No1 A tab";

    fontStyle = "Normal";

    pointSize = 8.75;

    head = 10;

    alignToBaseline = true;

    Justification = Justification.LEFT_JUSTIFIED;

    keepFirstLines = 2;

    tabStops [0] .alignment = TabStopAlignment.CENTER_ALIGN;

    .leader tabStops = [0] ";

    tabStops .position [0] = 5;

    crashes here

    tabStops [1] .alignment = TabStopAlignment.CENTER_ALIGN;

    .leader tabStops [1] = ";

    tabStops [1] .position = 10;

    tabStops [2] .alignment = TabStopAlignment.CENTER_ALIGN;

    .leader tabStops [2] = ";

    tabStops [2] .position = 15;

    tabStops [3] .alignment = TabStopAlignment.CENTER_ALIGN;

    .leader tabStops [3] = ";

    tabStops [3] .position = 20;

    }

    }

    It is possible using tabList. Here is a code that did this and sets all the properties at the same time. "with" does NOT define the properties at the same time and should always be avoided.

    var myParagraphStyle = app.documents[0].paragraphStyles.item("Verse");
    myParagraphStyle.properties = {
      tabList:[
        {
          position: 5,
          alignment: TabStopAlignment.CENTER_ALIGN,
          leader: ""
        },
        {
          position: 10,
          alignment: TabStopAlignment.CENTER_ALIGN,
          leader: ""
        },
        {
          position: 15,
          alignment: TabStopAlignment.CENTER_ALIGN,
          leader: ""
        }
      ],
      appliedFont: "Lexicon No1 A Tab",
      fontStyle: "Normal",
      pointSize: 8.75,
      leading: 10,
      alignToBaseline: true,
      justification: Justification.LEFT_JUSTIFIED,
      keepFirstLines: 2
    };
    
  • Is it possible to add multiple contours on the same layer?

    Hello! I am trying to add a stroke to text or objects through the style fx, so I want to add more contours. Would be nice if you could just add a new line as in illustrator. I don't want to copy the layer and just do a wider edge behind it, the fact is that it is all on the same layer... I was wondering if this is possible. Thank you!

    Click on the gradient to edit and make your own gradient using multiple transition points to make transitions very abrupt...

    -Christmas

  • is it possible to edit multiple pages at the same time no one-by-one?

    Hi all

    Sorry I'm new here... and I would like to know if dreamweaver can change a url or a name of title for all my pages before you download them... say 100 pages at a time without having to suffer the same amendments one by one.

    is this possible? or...

    ----------------------------------------------------

    Medo Joe

    How to earn money at home

    No necessary headache.

    Offers Dreamweaver templates and library items (both are features of DW who work locally).

    The web offers generically Server Side Includes (not a specific feature of DW, work server side, where the name)

    The downside of templates and library items, is that once you have updated the model or library item (code snippet) and then locally update all pages that exploit them, you then upload to the server all the pages that have changed. Could be hundreds of pages to download whenever you perform a single edition.

    Server Side Includes are much better. They are extracted from files that are "included" in the page on the server when the page is sent to the browser. Make a unique edition in a single file Include (for example your Sidebar). Download a tiny Include file. All pages in your Web site are instantly updated.

    SSIs are perfect for navbars, boxes, headers, footers, copyright notice, price lists etc. Any repetitive content that appears on several pages really.

    For me, SSIs changed the maintenance of the website of a dreaded chore (templates and library items) in a pleasure that I am happy to do it regularly.

Maybe you are looking for

  • Re: Win8 Installationsur L450D-13 X

    I have a Toshiba Satellite L450D - 13 X and I would install Windows 8 if anyone can help a pensioner / he installed Windows 7. I thank in advance Ken

  • With the HP G7000 laptop screen problem

    Hello I bought a HP G7000 laptop pre-installed with Windows Vista Home Premium x 86 a few days, the problem with him, it was that the screen wouldn't turn on even when it is plugged into the laptop is connected using the adapter I had also buy separa

  • Quando o computador diz Québec ligo is um problema recuperou

    desligo o computador usually e quando ligo appears a mensagem as ele to um problema recuperou

  • Recovery and partition

    Hello! I have a HP Pavilion dv6-6b57er with 1 TB HDD and I want to divide it into 2 logical drives, so the question is: after that will be I make recovery media disk? I guess, it is on the flash/ssd or something, but I'm not sure. THX

  • How do I set the background / highlight on the listView when select multi use

    Hi, I'm used to select multi on the list view, the problem is when the selected item does not change the background (I think by default will change in light blue) Maybe because I'm not using StandardListItem on itemList, I use clean container for ite