Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4119612
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:06:47+00:00 2026-05-20T23:06:47+00:00

Here is how my xml looks like : <Company xmlns =http://abc.com/rules> <Employee id=E1 number=0000007535>

  • 0

Here is how my xml looks like :

<Company xmlns ="http://abc.com/rules">
<Employee id="E1" number="0000007535">
   <Payment disposition="Open" type="ABC" amount_paid="100.00" />
   <Payment disposition="Closed" type="XYZ" amount_paid="468.00" />
   <Payment disposition="Open" type="AOD" amount_paid="156.00" />
   <Payment disposition="Closed" type="ONB" amount_paid="2834.00" />
</ Employee >
<Employee id="E1" number="0000007536">
   <Payment disposition="Open" type="DFG" amount_paid="200.00" />
   <Payment disposition="Closed" type="HFK" amount_paid="568.00" />
</ Employee >
<Employee id="E1" number="0000007537">
   <Payment disposition="Open" type="TTT" amount_paid="600.00" />
   <Payment disposition="Closed" type="BBB" amount_paid="368.00" />
</ Employee >
<Employee id="E2" number="0000007541">
   <Payment disposition="Open" type="EEE" amount_paid="0.00" />
   <Payment disposition="Closed" type="WWW" amount_paid="568.00" />
   <Payment disposition="Closed" type="GHW" amount_paid="968.00" />
</ Employee >
<Employee id="E2" number="0000007542">
   <Payment disposition="Open" type="QQQ" amount_paid="140.00" />
   <Payment disposition="Closed" type="CCC" amount_paid="68.00" />
</ Employee >
<Employee id="E3" number="0000007551">
   <Payment disposition="Open" type="AAA" amount_paid="300.00" />
   <Payment disposition="Closed" type="TTT" amount_paid="668.00" />
</ Employee >
</ Company>

I need to get all the Payment info for each Employee

some thing like :

E1 0000007535 Open ABC 100.00

E1 0000007536 Closed XYZ 468.00

……

E2 0000007541 Open EEE 0.00
….

But the below code gives me only Dispositon,Type and AmountPaid I am not able to map it to each Employee.

;WITH XMLNAMESPACES (DEFAULT 'http://abc.com/rules') 
 select   Disposition,Type,AmountPaid from 
        EMPLOYEE
     OUTER APPLY
     (    
     SELECT 
     tbl.col.value('(@disposition)[1]','varchar(20)') AS Disposition, 
  tbl.col.value('(@type)[1]','varchar(20)') AS Type,
  tbl.col.value('(@amount_paid)[1]','varchar(20)') AS AmountPaid 

   FROM xmldocument.nodes('//Employee/Payment') AS tbl(col) 

 )Z  
WHERE xmlid = 500

Thanks
BB

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T23:06:47+00:00Added an answer on May 20, 2026 at 11:06 pm

    I do not really understand how this xml relates to the xmldocument column in your EMPLOYEE table. Is the xml split between rows in employee or do one employee have more than one employee in the xml? Anyway, here is a way to query the XML you have provided. Perhaps you can use this and adapt it to your situation.

    declare @xmldocument xml = '
    <Company xmlns="http://abc.com/rules">
        <Employee id="E1" number="0000007535">
            <Payment disposition="Open" type="ABC" amount_paid="100.00"/>
            <Payment disposition="Closed" type="XYZ" amount_paid="468.00"/>
            <Payment disposition="Open" type="AOD" amount_paid="156.00"/>
            <Payment disposition="Closed" type="ONB" amount_paid="2834.00"/>
        </Employee>
        <Employee id="E1" number="0000007536">
            <Payment disposition="Open" type="DFG" amount_paid="200.00"/>
            <Payment disposition="Closed" type="HFK" amount_paid="568.00"/>
        </Employee>
        <Employee id="E1" number="0000007537">
            <Payment disposition="Open" type="TTT" amount_paid="600.00"/>
            <Payment disposition="Closed" type="BBB" amount_paid="368.00"/>
        </Employee>
        <Employee id="E2" number="0000007541">
            <Payment disposition="Open" type="EEE" amount_paid="0.00"/>
            <Payment disposition="Closed" type="WWW" amount_paid="568.00"/>
            <Payment disposition="Closed" type="GHW" amount_paid="968.00"/>
        </Employee>
        <Employee id="E2" number="0000007542">
            <Payment disposition="Open" type="QQQ" amount_paid="140.00"/>
            <Payment disposition="Closed" type="CCC" amount_paid="68.00"/>
        </Employee>
        <Employee id="E3" number="0000007551">
            <Payment disposition="Open" type="AAA" amount_paid="300.00"/>
            <Payment disposition="Closed" type="TTT" amount_paid="668.00"/>
        </Employee>
    </Company>'
    
    ;with xmlnamespaces(default 'http://abc.com/rules')
    select 
      p.value('../@id', 'varchar(10)'),
      p.value('../@number', 'varchar(10)'),
      p.value('@disposition', 'varchar(10)'),
      p.value('@type', 'varchar(10)'),
      p.value('@amount_paid', 'varchar(10)')
    from @xmldocument.nodes('Company/Employee/Payment') n(p)
    

    Result

    ---------- ---------- ---------- ---------- ----------
    E1         0000007535 Open       ABC        100.00
    E1         0000007535 Closed     XYZ        468.00
    E1         0000007535 Open       AOD        156.00
    E1         0000007535 Closed     ONB        2834.00
    E1         0000007536 Open       DFG        200.00
    E1         0000007536 Closed     HFK        568.00
    E1         0000007537 Open       TTT        600.00
    E1         0000007537 Closed     BBB        368.00
    E2         0000007541 Open       EEE        0.00
    E2         0000007541 Closed     WWW        568.00
    E2         0000007541 Closed     GHW        968.00
    E2         0000007542 Open       QQQ        140.00
    E2         0000007542 Closed     CCC        68.00
    E3         0000007551 Open       AAA        300.00
    E3         0000007551 Closed     TTT        668.00
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's an XML file I want to import into Cocoa: <?xml version='1.0'?> <Root xmlns='http://www.abc.uk'
Here is my XML Response: <DIDL-Lite xmlns=urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/ xmlns:dc=http://purl.org/dc/elements/1.1/ xmlns:upnp=urn:schemas-upnp-org:metadata-1-0/upnp/ <item id=1182 parentID=40 restricted=1> <title>Hot
Here's the XML: <?xml version='1.0' encoding='UTF-8' standalone='yes' ?> <feed xmlns=http://www.w3.org/2005/Atom xmlns:dc=http://purl.org/dc/elements/1.1/> <title>Rated Images</title> <link
Here is what my XML looks like (I'm calling XML using JSON) <shishir> <english>
Here's what part of my ivy.xml looks like right now: <dependency org=org.springframework name=org.springframework.core rev=3.0.2.RELEASE
Here is how my XML looks like. I am trying to query XML in
I am starting out with xml and vb.net here, my xml looks like this:
here is the XML file : <com.google.android.maps.MapView android:layout_width=fill_parent android:layout_height=fill_parent android:apiKey=0q7NUYm4bgzeXlqXtKYVPJDRWUJmt8Cu0gvbWMx android:id=@+id/map_view /> and Manifest
I made a plist that looks like that: <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE plist PUBLIC
I am getting this exception when mapping one-to-many relation. my mapping xml looks like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.