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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:17:32+00:00 2026-06-10T22:17:32+00:00

I am working with VMware vCenter 5 and want to create a quick report

  • 0

I am working with VMware vCenter 5 and want to create a quick report of the DRS rules that have been created. Below is an excerpt of the data:

<obj xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:vim25" versionId="5.0" xsi:type="ArrayOfClusterRuleInfo">
  <ClusterRuleInfo xsi:type="ClusterAffinityRuleSpec">
    <key>1</key>
    <enabled>true</enabled>
    <name>SQL Servers</name>
    <vm type="VirtualMachine" xsi:type="ManagedObjectReference">vm-100</vm>
    <vm type="VirtualMachine" xsi:type="ManagedObjectReference">vm-200</vm>
    <vm type="VirtualMachine" xsi:type="ManagedObjectReference">vm-300</vm>
  </ClusterRuleInfo>
  <ClusterRuleInfo xsi:type="ClusterAntiAffinityRuleSpec">
    <key>2</key>
    <enabled>true</enabled>
    <name>Oracle DBs</name>
    <vm type="VirtualMachine" xsi:type="ManagedObjectReference">vm-1000</vm>
    <vm type="VirtualMachine" xsi:type="ManagedObjectReference">vm-2000</vm>
  </ClusterRuleInfo>
</obj>

Note that the number of VMs per rule may differ.

I have not been able to turn this XML data into a table, so I tried locating just the name (within the tags) with this query:

SELECT ref.value('name[1]', 'varchar(200)') as [enabled]
FROM @data.nodes('/obj/ClusterRuleInfo') data( ref )

It returns no data. I found that if I remove the and lines, it works, but I’m not sure why. I believe it is because SQL Server does not understand the XML schema (or something similar – I’m not an XML expert).

In the end, I’d like to see a table like this:

Name           VM
-----------   ----
SQL Servers    100
SQL Servers    200
SQL Servers    300
Oracle DBs    1000
Oracle DBs    2000
  • 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-06-10T22:17:34+00:00Added an answer on June 10, 2026 at 10:17 pm

    Your XML uses a namespace, so you need the WITH XMLNAMESPACES clause:

    declare @data xml;
    set @data = '
    <obj xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:vim25" versionId="5.0" xsi:type="ArrayOfClusterRuleInfo">
      <ClusterRuleInfo xsi:type="ClusterAffinityRuleSpec">
        <key>1</key>
        <enabled>true</enabled>
        <name>SQL Servers</name>
        <vm type="VirtualMachine" xsi:type="ManagedObjectReference">vm-100</vm>
        <vm type="VirtualMachine" xsi:type="ManagedObjectReference">vm-200</vm>
        <vm type="VirtualMachine" xsi:type="ManagedObjectReference">vm-300</vm>
      </ClusterRuleInfo>
      <ClusterRuleInfo xsi:type="ClusterAntiAffinityRuleSpec">
        <key>2</key>
        <enabled>true</enabled>
        <name>Oracle DBs</name>
        <vm type="VirtualMachine" xsi:type="ManagedObjectReference">vm-1000</vm>
        <vm type="VirtualMachine" xsi:type="ManagedObjectReference">vm-2000</vm>
      </ClusterRuleInfo>
    </obj>';
    
    WITH XMLNAMESPACES('urn:vim25' AS ns)
    SELECT 
      ref.value('../ns:name[1]','nvarchar(256)') AS Name, 
      STUFF(ref.value('.','nvarchar(256)'),1,3,'') AS VM
    FROM @data.nodes('/ns:obj/ns:ClusterRuleInfo/ns:vm') data( ref );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application that is working fine under the following environment GWT
I have a VmWare virtual machine that is coming dangerously close to it's primarry
I have VMware setup for testing. I create one user abc/abc123 to access the
Have a set of prototype-enabled ajax code that is working in all browsers other
I have an application that works with physical memory snapshots (for example, VMware VMEM
Working with an undisclosed API, I found a function that can set the number
Working with Reporting Services 2008 r2. So here's my issue: We have 5 reports
I'm currently working with the vmrun-Tool, to control VMWare Virtual Machines. I'm using VMWareWorkstation
Working on an extension that use the new experimental devtools apis. How do you
I am working on Ubuntu 9.04. I am running this on VMware workstation. Here

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.