Hi,
i have a small problem with Linq to XML:
The following lines are written with VB 2008 / .Net 3.5
Code Snippet
Option Strict On
Imports http://mytarget.sample.com/linq2xml">
Imports System.Xml.Linq
Imports System.Xml
Imports System.Linq
Module Module1
Sub Main()
Dim mytest = <?xml version="1.0" encoding="utf-8"?>
<myroot xmlns="http://mytarget.sample.com/linq2xml">
<Sample MyAttribute="12">This is a Test</Sample>
<numVal>12</numVal>
</myroot>
Dim myAttr = From myxml In mytest.<myroot> _
Where myxml.<numVal>.Value = 12 ' this is the Error-Line
'Where myxml.<Sample>.@MyAttribute = 12
End Sub
End Module
i get the error message "Option Strict On disallows implicit conversions from 'String' to 'Double'"
at "Where myxml.<numVal>.Value = 12". I get the same error in the line "Where myxml.<Sample>.@MyAttribute = 12".
This is the generated XSD File
Code Snippet
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://mytarget.sample.com/linq2xml" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="myroot">
<xs:complexType>
<xs:sequence>
<xs:element name="Sample">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="MyAttribute" type="xs:unsignedByte" use="required" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="numVal" type="xs:unsignedByte" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Intellisense works fine with this, but there is no implicit Type-Conversion from String to integer/unsignedByte.
best regards,
Andreas B