I was provided an XSD file to fill in a value in XML i am generating for submitting to a web service.
The XSD defines values for Enumerations that contain annotations and other info. Best way to describe is to show some of the XSD.
<?xml version="1.0" encoding="utf-16" ?>
<xs:schema xmlns="http://MyCompany/Schemas" xmlns:b="http://schemas.microsoft.com/BizTalk /2003" elementFormDefault="qualified" targetNamespace="http://MyCompany/Schemas" id="NAICSTypes" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="NAICSType">
<xs:restriction base="xs:int">
<xs:enumeration value="111110">
<xs:annotation>
<xs:appinfo>2007 NAICS Title</xs:appinfo>
<xs:documentation xml:lang="en-us">Soybean Farming</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="111120">
<xs:annotation>
<xs:appinfo>2007 NAICS Title</xs:appinfo>
<xs:documentation xml:lang="en-us">Oilseed (except Soybean) Farming</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="111130">
<xs:annotation>
<xs:appinfo>2007 NAICS Title</xs:appinfo>
<xs:documentation xml:lang="en-us">Dry Pea and Bean Farming</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="111140">
<xs:annotation>
<xs:appinfo>2007 NAICS Title</xs:appinfo>
<xs:documentation xml:lang="en-us">Wheat Farming</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="111150">
<xs:annotation>
<xs:appinfo>2007 NAICS Title</xs:appinfo>
<xs:documentation xml:lang="en-us">Corn Farming</xs:documentation>
</xs:annotation>
</xs:enumeration>
Essentially, what i need to do is provide a value, like 111150, and get back “Corn Farming” as a result in c#
Any Suggestions?
To just query the XML you can use SelectNodes or SelectSingleNode. You’ll also need to specify a namespace manager to the query.
Something like this: