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 6849799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:02:26+00:00 2026-05-27T01:02:26+00:00

I am really new to XMl and have been tasked with extracting some values

  • 0

I am really new to XMl and have been tasked with extracting some values from an XML column.

I have read LOTS of example of how to do this on the internet and on here and have tried several different methods. Whilst I can get these to work, they only return null values so clearly something isn’t going right. The only difference I can see is that in our XML code they use SOAP. A previous developer wrote the code and so I cannot ask them.

These are the methods I have tried:


SELECT
  settings.value('item[1]/_value[1]', 'int') as PrinterId
      FROM dbo.usersettings 
    where userid = 2156

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

 create table XMLPrinters (PrinterList xml)
   insert XMLPrinters select settings 
       from dbo.UserSettings
            where userid = 2156

select 
    r.p.value ('item[1]/_key[1]', 'nvarchar (50)') as PrinterType,
    r.p.value ('item[1]/_value[1]', 'int') as PrinterId 
from XMLPrinters 
    cross apply printerlist.nodes ('//item') r(p)

As I say, I am very new to XML and don’t come from a coding background so there probably is something I am missing, but the XML code doesn’t seem to fit other formats I have seen on the web, and I guess this is probably due to the SOAP.

The code itself is 2496 lines long, but this is an extract from the beginning where I am trying to extract the values from:

         <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"                             xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
               xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
               xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
               xmlns:clr="http://schemas.microsoft.com/soap/encoding/clr/1.0" 
               SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<SOAP-ENC:Array SOAP-ENC:arrayType="xsd:anyType[5]">
  <item xmlns:a2="http://schemas.microsoft.com/clr/ns/System.Collections"                     xsi:type="a2:DictionaryEntry">
    <_key xsi:type="xsd:string">primaryprinter</_key>
    <_value xsi:type="xsd:anyType" xsi:null="1" />
  </item>

  <item xmlns:a2="http://schemas.microsoft.com/clr/ns/System.Collections" xsi:type="a2:DictionaryEntry">
    <_key xsi:type="xsd:string">secondaryprinter</_key>
    <_value xsi:type="xsd:anyType" xsi:null="1" />
  </item>

  <item xmlns:a2="http://schemas.microsoft.com/clr/ns/System.Collections" si:type="a2:DictionaryEntry">
    <_key xsi:type="xsd:string">i18mminstancelabel</_key>
    <_value xsi:type="xsd:string">1056</_value>
  </item>

Eventually what I need to do is to extract the _value where _key = PrimaryPrinter and do this for each user.

Any help or ideas anyone has would be greatly received!

Regards

Julie

  • 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-27T01:02:27+00:00Added an answer on May 27, 2026 at 1:02 am

    Don’t actually understand what your first query does. But the second will work if you remove item[1]/ from the xpath where you fetch the values.

    select 
        r.p.value ('_key[1]', 'nvarchar (50)') as PrinterType,
        r.p.value ('_value[1]', 'int') as PrinterId 
    from XMLPrinters 
        cross apply printerlist.nodes ('//item') r(p)
    

    Result with the XML you provided:

    PrinterType                                        PrinterId
    -------------------------------------------------- -----------
    primaryprinter                                     0
    secondaryprinter                                   0
    i18mminstancelabel                                 1056
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am really new to Python and I have been looking for an example
We have been given some code that does a URLRequest call which is really
I have been troubleshooting this for a while, and I am kind of new
I am really new to XML and JDOM so I have a noob question,
I'm really new to Perl and a first timer to XML::Simple . I have
I have been dealing with a problem for some time and would really appreciate
I'm really new to erlang and I'm wondering how to manipulate xml. I've found
im really new to linq-to-SQL so this may sound like a really dumb question,
I'm really new to VSTO so sorry if this is a newbie question. I'm
There have been a few questions like this around the place but none have

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.