Parse KML file with vba - vba

I am trying to get 2 pieces of information from a KML file. I have some code (ref:K Buttters) in vba (as I want to add the data to a db). This code works perfectly and returns the coordinates, but I want to also get the data for the name tag. How do I amend the code to get this extra piece of information. information. Thanks
Public Sub readFile()
Dim objXML As MSXML2.DOMDocument60
Dim ns As String
Dim nodelist As IXMLDOMNodeList
Dim coordNode As IXMLDOMNode
Dim XPath As String
Dim Namespace As String
Dim i As Integer
'Create the DomDocument Object
'Set objXML = CreateObject("MSXML2.DOMDocument60")
Set objXML = New MSXML2.DOMDocument60
'Load entire Document before moving on
objXML.async = False
'Don't Validate
objXML.validateOnParse = False
'Read in the file
objXML.Load ("C:\pcsect2.kml")
''''''''''''''''''''''''''''''
' Set up the appropriate (default) namespace
''''''''''''''''''''''''''''''
Namespace = "xmlns:ns='http://www.opengis.net/kml/2.2'"
Call objXML.SetProperty("SelectionNamespaces", Namespace)
Call objXML.SetProperty("SelectionLanguage", "XPath")
''''''''''''''''''''''''''''''
' Define the XPath to get to coordinates
''''''''''''''''''''''''''''''
XPath = "//ns:coordinates"
''''''''''''''''''''''''''''''
' Select All "coordinates" nodes
''''''''''''''''''''''''''''''
Set nodelist = objXML.SelectNodes(XPath)
''''''''''''''''''''''''''''''
' Nodelist contains all the Coordinates...
' note: Under view ... set immediate window to viewable to see the debug.print results...
''''''''''''''''''''''''''''''
For i = 0 To nodelist.Length - 1
Set coordNode = nodelist.NextNode
Debug.Print coordNode.Text
Next i
End Sub
kml file:
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<description><![CDATA[UK postcode polygons]]></description>
<Style id="stylePostcode">
<LineStyle>
<width>3</width>
</LineStyle>
<PolyStyle>
<color>00ff0000</color>
</PolyStyle>
</Style>
<Style id="stylePostcode" xmlns="http://www.opengis.net/kml/2.2">
<LineStyle>
<width>3</width>
</LineStyle>
<PolyStyle>
<color>00ff0000</color>
</PolyStyle>
</Style>
<Folder xmlns="http://www.opengis.net/kml/2.2">
<name>AB10</name>
<description><![CDATA[Postcode sectors in the AB10 postcode district]]></description>
<Placemark>
<name>AB10 1</name>
<styleUrl>#stylePostcode</styleUrl>
<description><![CDATA[AB10 1 postcode sector]]></description>
<MultiGeometry>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
-2.09646046762775,57.1512327554617 -2.0962834594401,57.1506128321186 -2.09610247782767
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
-2.10596557515499,57.1385921418501 -2.10604057319705,57.1387481221535
</LinearRing>
</outerBoundaryIs>
</Polygon>
</MultiGeometry>
</Placemark>
<Placemark>
<name>AB10 6</name>
<styleUrl>#stylePostcode</styleUrl>
<description><![CDATA[AB10 6 postcode sector</a>]]></description>
<MultiGeometry>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
-2.11311153246704,57.1365722876569 -2.11309853402536,57.1365692881912
</LinearRing>
</outerBoundaryIs>
</Polygon>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
-2.1113360807897,57.1427795678869 -2.11112010338182,57.1426645845693
</LinearRing>
</outerBoundaryIs>
</Polygon>
</MultiGeometry>
</Placemark>
<Placemark>
<name>AB10 7</name>
<styleUrl>#stylePostcode</styleUrl>
<description><![CDATA[AB10 7 postcode sector>Details</a>]]></description>
<MultiGeometry>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
-2.11383946866067,57.1372032022769 -2.11366248946505,57.1371542105275
</LinearRing>
</outerBoundaryIs>
</Polygon>
</MultiGeometry>
</Placemark>
</Folder>
<Style id="stylePostcode" xmlns="http://www.opengis.net/kml/2.2">
<LineStyle>
<width>3</width>
</LineStyle>
<PolyStyle>
<color>00ff0000</color>
</PolyStyle>
</Style>
<Folder xmlns="http://www.opengis.net/kml/2.2">
<name>ZE3</name>
<description><![CDATA[Postcode sectors in the ZE3 postcode district]]></description>
<Placemark>
<name>ZE3 9</name>
<styleUrl>#stylePostcode</styleUrl>
<description><![CDATA[ZE3 9 postcode sector>Details</a>]]></description>
<MultiGeometry>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
-1.33983120448744,59.8989006252828 -1.32301876923355,59.9016455421112
</LinearRing>
</outerBoundaryIs>
</Polygon>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
-1.32885903137389,59.8719950412819 -1.33463302343859,59.8690613106313
</LinearRing>
</outerBoundaryIs>
</Polygon>
</MultiGeometry>
</Placemark>
</Folder>
</Document>
</kml>

Related

Parse xml file in pandas

I have this xml file (it's called "LogReg.xml" and it contains some information about a logistic regression (I am interested in the name of the features and their coefficient - I'll explain in more detail below):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<PMML xmlns="http://www.dmg.org/PMML-4_4" xmlns:data="http://jpmml.org/jpmml-model/InlineTable" version="4.4">
<Header>
<Application name="JPMML-SkLearn" version="1.6.35"/>
<Timestamp>2022-02-15T09:44:54Z</Timestamp>
</Header>
<MiningBuildTask>
<Extension name="repr">PMMLPipeline(steps=[('classifier', LogisticRegression())])</Extension>
</MiningBuildTask>
<DataDictionary>
<DataField name="Target" optype="categorical" dataType="integer">
<Value value="0"/>
<Value value="1"/>
</DataField>
<DataField name="const" optype="continuous" dataType="double"/>
<DataField name="grade" optype="continuous" dataType="double"/>
<DataField name="emp_length" optype="continuous" dataType="double"/>
<DataField name="dti" optype="continuous" dataType="double"/>
<DataField name="Orig_FicoScore" optype="continuous" dataType="double"/>
<DataField name="inq_last_6mths" optype="continuous" dataType="double"/>
<DataField name="acc_open_past_24mths" optype="continuous" dataType="double"/>
<DataField name="mort_acc" optype="continuous" dataType="double"/>
<DataField name="mths_since_recent_bc" optype="continuous" dataType="double"/>
<DataField name="num_rev_tl_bal_gt_0" optype="continuous" dataType="double"/>
<DataField name="percent_bc_gt_75" optype="continuous" dataType="double"/>
</DataDictionary>
<RegressionModel functionName="classification" algorithmName="sklearn.linear_model._logistic.LogisticRegression" normalizationMethod="logit">
<MiningSchema>
<MiningField name="Target" usageType="target"/>
<MiningField name="const"/>
<MiningField name="grade"/>
<MiningField name="emp_length"/>
<MiningField name="dti"/>
<MiningField name="Orig_FicoScore"/>
<MiningField name="inq_last_6mths"/>
<MiningField name="acc_open_past_24mths"/>
<MiningField name="mort_acc"/>
<MiningField name="mths_since_recent_bc"/>
<MiningField name="num_rev_tl_bal_gt_0"/>
<MiningField name="percent_bc_gt_75"/>
</MiningSchema>
<Output>
<OutputField name="probability(0)" optype="continuous" dataType="double" feature="probability" value="0"/>
<OutputField name="probability(1)" optype="continuous" dataType="double" feature="probability" value="1"/>
</Output>
<RegressionTable intercept="0.8064694059338298" targetCategory="1">
<NumericPredictor name="const" coefficient="0.8013433785974717"/>
<NumericPredictor name="grade" coefficient="0.9010481046582982"/>
<NumericPredictor name="emp_length" coefficient="0.9460686056314133"/>
<NumericPredictor name="dti" coefficient="0.5117062988491518"/>
<NumericPredictor name="Orig_FicoScore" coefficient="0.07944303372859234"/>
<NumericPredictor name="inq_last_6mths" coefficient="0.20516234445402765"/>
<NumericPredictor name="acc_open_past_24mths" coefficient="0.4852503249658917"/>
<NumericPredictor name="mort_acc" coefficient="0.6673203078463711"/>
<NumericPredictor name="mths_since_recent_bc" coefficient="0.1962158305958366"/>
<NumericPredictor name="num_rev_tl_bal_gt_0" coefficient="0.12964661294856686"/>
<NumericPredictor name="percent_bc_gt_75" coefficient="0.04534570018290847"/>
</RegressionTable>
<RegressionTable intercept="0.0" targetCategory="0"/>
</RegressionModel>
</PMML>
I have parsed it using this code:
from lxml import objectify
path = 'LogReg.xml'
parsed = objectify.parse(open(path))
root = parsed.getroot()
data = []
if True:
for elt in root.RegressionModel.RegressionTable:
el_data = {}
for child in elt.getchildren():
el_data[child.tag] = child.text
data.append(el_data)
perf = pd.DataFrame(data)
I am interested in parsing this bit:
<RegressionTable intercept="0.8064694059338298" targetCategory="1">
<NumericPredictor name="const" coefficient="0.8013433785974717"/>
<NumericPredictor name="grade" coefficient="0.9010481046582982"/>
<NumericPredictor name="emp_length" coefficient="0.9460686056314133"/>
<NumericPredictor name="dti" coefficient="0.5117062988491518"/>
<NumericPredictor name="Orig_FicoScore" coefficient="0.07944303372859234"/>
<NumericPredictor name="inq_last_6mths" coefficient="0.20516234445402765"/>
<NumericPredictor name="acc_open_past_24mths" coefficient="0.4852503249658917"/>
<NumericPredictor name="mort_acc" coefficient="0.6673203078463711"/>
<NumericPredictor name="mths_since_recent_bc" coefficient="0.1962158305958366"/>
<NumericPredictor name="num_rev_tl_bal_gt_0" coefficient="0.12964661294856686"/>
<NumericPredictor name="percent_bc_gt_75" coefficient="0.04534570018290847"/>
</RegressionTable>
so that I can build the following dictionary:
myDict = {
"const : 0.8013433785974717,
"grade" : 0.9010481046582982,
"emp_length" : 0.9460686056314133,
"dti" : 0.5117062988491518,
"Orig_FicoScore" : 0.07944303372859234,
"inq_last_6mths" : 0.20516234445402765,
"acc_open_past_24mths" : 0.4852503249658917,
"mort_acc" : 0.6673203078463711,
"mths_since_recent_bc" : 0.1962158305958366,
"num_rev_tl_bal_gt_0" : 0.12964661294856686,
"percent_bc_gt_75" : 0.04534570018290847
}
Basically, in the dictionary the Key is the name of the feature and the value is the coefficient of the logistic regression.
Please can anyone help me with the code?
I'm not sure you need pandas for this, but you do need to handle the namespaces in your xml.
Try something along these lines:
myDict = {}
#register the namespace
ns = {'xx': 'http://www.dmg.org/PMML-4_4'}
#you could collapse the next two into one line, but I believe it's clearer this way
rt = root.xpath('//xx:RegressionTable[.//xx:NumericPredictor]',namespaces=ns)[0]
nps = rt.xpath('./xx:NumericPredictor',namespaces=ns)
for np in nps:
myDict[np.attrib['name']]=np.attrib['coefficient']
myDict
The output should be your expected output.

Ebay motors api - Category is not valid. ID 33562

Trying to post the item in ebay motors using ebay api call - AddItem. It throws me an error saying as below. Could you please show some light on this.
Note - I am able to add the item manually in ebay motors with compatability. I fetched the item details (which is added manually) using the api call - GetItem. Placed the same details in the AddItem api call. Though it got failed with below error.
<ShortMessage>Category is not valid.</ShortMessage>
<LongMessage>The category is not valid, select another category.</LongMessage>
<ErrorCode>107</ErrorCode>
<SeverityCode>Error</SeverityCode>
<ErrorClassification>RequestError</ErrorClassification>
Request message is
<?xml version="1.0" encoding="UTF-8"?>
<AddItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<RequesterCredentials>
<eBayAuthToken>********PG1QKFIlH****</eBayAuthToken>
</RequesterCredentials>
<Version>967</Version>
<ErrorLanguage>en_US</ErrorLanguage>
<WarningLevel>High</WarningLevel>
<Item>
<Title>Sample ebay motor brake fitment product</Title>
<Description>Hummer Truck Right Side Mirror</Description>
<StartPrice currencyID="USD">236.0</StartPrice>
<Country>US</Country>
<Currency>USD</Currency>
<ListingDuration>Days_7</ListingDuration>
<Location>Los Angeles, California</Location>
<DispatchTimeMax>2</DispatchTimeMax>
<ConditionID>1000</ConditionID>
<PaymentMethods>PayPal</PaymentMethods>
<PayPalEmailAddress>w*****1#gmail.com</PayPalEmailAddress>
<Quantity>1</Quantity>
<PrimaryCategory>
<CategoryID>33562</CategoryID>
</PrimaryCategory>
<PictureDetails>
<GalleryType>Gallery</GalleryType>
<GalleryURL>http://****/z/QJsAAOSwXSJXPHk~/$_1.JPG?set_id=880000500F</GalleryURL>
<PhotoDisplay>PicturePack</PhotoDisplay>
<PictureURL>http://*****/z/QJsAAOSwXSJXPHk~/$_1.JPG?set_id=880000500F</PictureURL>
</PictureDetails>
<ShippingDetails>
<ApplyShippingDiscount>false</ApplyShippingDiscount>
<GlobalShipping>true</GlobalShipping>
<CalculatedShippingRate>
<WeightMajor measurementSystem="English" unit="lbs">0</WeightMajor>
<WeightMinor measurementSystem="English" unit="oz">0</WeightMinor>
</CalculatedShippingRate>
<ShippingServiceOptions>
<ShippingService>ShippingMethodStandard</ShippingService>
<ShippingServiceCost currencyID="USD">0.0</ShippingServiceCost>
<ShippingServicePriority>1</ShippingServicePriority>
<ExpeditedService>false</ExpeditedService>
<ShippingTimeMin>1</ShippingTimeMin>
<ShippingTimeMax>6</ShippingTimeMax>
<FreeShipping>true</FreeShipping>
</ShippingServiceOptions>
<ShippingType>Flat</ShippingType>
<ThirdPartyCheckout>false</ThirdPartyCheckout>
<TaxTable>
<TaxJurisdiction>
<JurisdictionID>CA</JurisdictionID>
<SalesTaxPercent>10.0</SalesTaxPercent>
<ShippingIncludedInTax>false</ShippingIncludedInTax>
</TaxJurisdiction>
</TaxTable>
<ShippingDiscountProfileID>0</ShippingDiscountProfileID>
<InternationalShippingDiscountProfileID>0</InternationalShippingDiscountProfileID>
<ExcludeShipToLocation>Alaska/Hawaii</ExcludeShipToLocation>
<ExcludeShipToLocation>US Protectorates</ExcludeShipToLocation>
<ExcludeShipToLocation>APO/FPO</ExcludeShipToLocation>
<ExcludeShipToLocation>Africa</ExcludeShipToLocation>
<ExcludeShipToLocation>Asia</ExcludeShipToLocation>
<ExcludeShipToLocation>Central America and Caribbean</ExcludeShipToLocation>
<ExcludeShipToLocation>Europe</ExcludeShipToLocation>
<ExcludeShipToLocation>Middle East</ExcludeShipToLocation>
<ExcludeShipToLocation>Oceania</ExcludeShipToLocation>
<ExcludeShipToLocation>Southeast Asia</ExcludeShipToLocation>
<ExcludeShipToLocation>South America</ExcludeShipToLocation>
<ExcludeShipToLocation>BM</ExcludeShipToLocation>
<ExcludeShipToLocation>GL</ExcludeShipToLocation>
<ExcludeShipToLocation>MX</ExcludeShipToLocation>
<ExcludeShipToLocation>PM</ExcludeShipToLocation>
<ExcludeShipToLocation>PO Box</ExcludeShipToLocation>
<SellerExcludeShipToLocationsPreference>true</SellerExcludeShipToLocationsPreference>
</ShippingDetails>
<ReturnPolicy>
<RefundOption>MoneyBack</RefundOption>
<Refund>Money Back</Refund>
<ReturnsWithinOption>Days_14</ReturnsWithinOption>
<ReturnsWithin>14 Days</ReturnsWithin>
<ReturnsAcceptedOption>ReturnsAccepted</ReturnsAcceptedOption>
<ReturnsAccepted>Returns Accepted</ReturnsAccepted>
<ShippingCostPaidByOption>Buyer</ShippingCostPaidByOption>
<ShippingCostPaidBy>Buyer</ShippingCostPaidBy>
<RestockingFeeValue>No</RestockingFeeValue>
<RestockingFeeValueOption>NoRestockingFee</RestockingFeeValueOption>
</ReturnPolicy>
<ItemCompatibilityList>
<Compatibility>
<NameValueList/>
<NameValueList>
<Name>Year</Name>
<Value>2008</Value>
</NameValueList>
<NameValueList>
<Name>Make</Name>
<Value>Workhorse Custom Chassis</Value>
</NameValueList>
<NameValueList>
<Name>Model</Name>
<Value>R26</Value>
</NameValueList>
<NameValueList>
<Name>Trim</Name>
<Value>Base Motor Home - Stripped Chassis</Value>
</NameValueList>
<NameValueList>
<Name>Engine</Name>
<Value>8.1L 496Cu. In. V8 GAS OHV Naturally Aspirated</Value>
</NameValueList>
<CompatibilityNotes></CompatibilityNotes>
</Compatibility>
<Compatibility>
<NameValueList/>
<NameValueList>
<Name>Year</Name>
<Value>1998</Value>
</NameValueList>
<NameValueList>
<Name>Make</Name>
<Value>Advance Mixer</Value>
</NameValueList>
<NameValueList>
<Name>Model</Name>
<Value>M</Value>
</NameValueList>
<NameValueList>
<Name>Trim</Name>
<Value>Base Straight Truck - Half Cab</Value>
</NameValueList>
<NameValueList>
<Name>Engine</Name>
<Value>-- DIESEL</Value>
</NameValueList>
<CompatibilityNotes></CompatibilityNotes>
</Compatibility>
<Compatibility>
<NameValueList/>
<NameValueList>
<Name>Year</Name>
<Value>1988</Value>
</NameValueList>
<NameValueList>
<Name>Make</Name>
<Value>Yugo</Value>
</NameValueList>
<NameValueList>
<Name>Model</Name>
<Value>GVS</Value>
</NameValueList>
<NameValueList>
<Name>Trim</Name>
<Value>Base Hatchback 3-Door</Value>
</NameValueList>
<NameValueList>
<Name>Engine</Name>
<Value>1.1L 1116CC l4 GAS SOHC Naturally Aspirated</Value>
</NameValueList>
<CompatibilityNotes></CompatibilityNotes>
</Compatibility>
<Compatibility>
<NameValueList/>
<NameValueList>
<Name>Year</Name>
<Value>1963</Value>
</NameValueList>
<NameValueList>
<Name>Make</Name>
<Value>Wolseley</Value>
</NameValueList>
<NameValueList>
<Name>Model</Name>
<Value>1500</Value>
</NameValueList>
<NameValueList>
<Name>Trim</Name>
<Value>Base</Value>
</NameValueList>
<NameValueList>
<Name>Engine</Name>
<Value>1.5L 1489CC 91Cu. In. l4 GAS OHV Naturally Aspirated</Value>
</NameValueList>
<CompatibilityNotes></CompatibilityNotes>
</Compatibility>
<Compatibility>
<NameValueList/>
<NameValueList>
<Name>Year</Name>
<Value>1928</Value>
</NameValueList>
<NameValueList>
<Name>Make</Name>
<Value>Yellow Cab</Value>
</NameValueList>
<NameValueList>
<Name>Model</Name>
<Value>Model D-1</Value>
</NameValueList>
<NameValueList>
<Name>Trim</Name>
<Value>Base</Value>
</NameValueList>
<NameValueList>
<Name>Engine</Name>
<Value>--</Value>
</NameValueList>
<CompatibilityNotes></CompatibilityNotes>
</Compatibility>
</ItemCompatibilityList>
</Item>
</AddItemRequest>
Make sure that you using the 100 as the value of the HTTP header X-EBAY-API-SITEID. This ensures that your request is routed to the eBay motors site where the category is valid. Using 0 in the header routes the request to ebay.com where the category is not valid.

Parsing XML by OpenXML with multiple Parent nodes with multiple child nodes

I have the following XML:
<Report>
<Accounts>
<Account>
<Currency>USD</Currency>
<AccountBalance>45555</AccountBalance>
<Payments>
<PaymentData>
<PaymentCode>502</PaymentCode>
<PaymentAmount currCode="GBP">7000.00000000</PaymentAmount>
</PaymentData>
<PaymentData>
<PaymentCode>501</PaymentCode>
<PaymentAmount currCode="USD">5000.00000000</PaymentAmount>
</PaymentData>
</Payments>
</Account>
<Account>
<Currency>USD</Currency>
<AccountBalance>50000</AccountBalance>
<Payments>
<PaymentData>
<PaymentCode>501</PaymentCode>
<PaymentAmount currCode="USD">5000.00000000</PaymentAmount>
</PaymentData>
</Payments>
</Account>
</Accounts>
</Report>
My SQL Code is parsing this with the following code:
SELECT
[currCode] AS [Currency],
[AccountBalance] AS [AccountBalance],
[PaymentCode] AS [PaymentCode],
[PaymentCurrCode] AS [PaymentCurrCode],
[PaymentAmount] AS [PaymentAmount]
FROM OPENXML(#hDoc, 'Report/Accounts/Account',2)
WITH
(
[currCode] [nchar](3) 'currCode',
[AccountBalance] [decimal](18, 0) 'AccountBalance',
[PaymentCode] [nchar](10) 'Payments/PaymentData/PaymentCode',
[PaymentCurrCode] [nchar](3) 'Payments/PaymentData/PaymentAmount/#currCode',
[PaymentAmount] [decimal](18, 0) 'Payments/PaymentData/PaymentAmount'
)
I am getting the following result:
currCode | AccountBalance | PaymentCode | PaymentCurrCode | PaymentAmount
————————————————————————————————————————————————————————————————————————————————
USD | 45555 | 502 | GBP |7000.00000000
USD | 50000 | 501 | USD |5000.00000000
I am trying to get the multiple paymentdata and multiple account with the same openXml query. How Can is get all the data with the following result:
currCode | AccountBalance | PaymentCode | PaymentCurrCode | PaymentAmount
————————————————————————————————————————————————————————————————————————————————
USD | 45555 | 502 | GBP |7000.00000000
USD | 45555 | 501 | USD |5000.00000000
USD | 50000 | 501 | USD |5000.00000000
This is an up-to-date and state-of-the-art approach with XQuery/XPath methods. The result is the same, just faster and better to read:
DECLARE #XML XML=
'<Report>
<Accounts>
<Account>
<Currency>USD</Currency>
<AccountBalance>45555</AccountBalance>
<Payments>
<PaymentData>
<PaymentCode>502</PaymentCode>
<PaymentAmount currCode="GBP">7000.00000000</PaymentAmount>
</PaymentData>
<PaymentData>
<PaymentCode>501</PaymentCode>
<PaymentAmount currCode="USD">5000.00000000</PaymentAmount>
</PaymentData>
</Payments>
</Account>
<Account>
<Currency>USD</Currency>
<AccountBalance>50000</AccountBalance>
<Payments>
<PaymentData>
<PaymentCode>501</PaymentCode>
<PaymentAmount currCode="USD">5000.00000000</PaymentAmount>
</PaymentData>
</Payments>
</Account>
</Accounts>
</Report>';
SELECT Payment.value('(../../Currency)[1]','nchar(3)') AS currCode
,Payment.value('(../../AccountBalance)[1]','decimal(18,0)') AS AccountBalance
,Payment.value('PaymentCode[1]','nchar(10)') AS PaymentCode
,Payment.value('PaymentAmount[1]/#currCode','nchar(3)') AS PaymentCurrCode
,Payment.value('PaymentAmount[1]','decimal(18,0)') AS PaymentCurrCode
FROM #XML.nodes('Report/Accounts/Account/Payments/PaymentData') AS One(Payment)
This should work for you:
DECLARE #XML XML=
'<Report>
<Accounts>
<Account>
<Currency>USD</Currency>
<AccountBalance>45555</AccountBalance>
<Payments>
<PaymentData>
<PaymentCode>502</PaymentCode>
<PaymentAmount currCode="GBP">7000.00000000</PaymentAmount>
</PaymentData>
<PaymentData>
<PaymentCode>501</PaymentCode>
<PaymentAmount currCode="USD">5000.00000000</PaymentAmount>
</PaymentData>
</Payments>
</Account>
<Account>
<Currency>USD</Currency>
<AccountBalance>50000</AccountBalance>
<Payments>
<PaymentData>
<PaymentCode>501</PaymentCode>
<PaymentAmount currCode="USD">5000.00000000</PaymentAmount>
</PaymentData>
</Payments>
</Account>
</Accounts>
</Report>';
DECLARE #hDoc INT;
EXEC sp_xml_preparedocument #hDoc OUTPUT, #XML;
SELECT
[currCode] AS [Currency],
[AccountBalance] AS [AccountBalance],
[PaymentCode] AS [PaymentCode],
[PaymentCurrCode] AS [PaymentCurrCode],
[PaymentAmount] AS [PaymentAmount]
FROM OPENXML(#hDoc, 'Report/Accounts/Account/Payments/PaymentData',2)
WITH
(
[currCode] [nchar](3) '../../Currency',
[AccountBalance] [decimal](18, 0) '../../AccountBalance',
[PaymentCode] [nchar](10) 'PaymentCode',
[PaymentCurrCode] [nchar](3) 'PaymentAmount/#currCode',
[PaymentAmount] [decimal](18, 0) 'PaymentAmount'
)
EXEC sp_xml_removedocument #hDoc;

xml file data imported to sql with script

im having this kind of xml:
<?xml version="1.0"?>
-<recordedData>
<machine>ZSK40-2</machine>
<date>2013/09/21</date>
<hour>05:32</hour>-<CollectedData>-<variable>
<Name>PRODUCT</Name>
<Value>FILLER 580</Value>
</variable>-<variable>
<Name>LOT_NUMBER</Name>
<Value>CG 00063 0</Value>
</variable>-<variable>
<Name>SHIFT_SUPERVISOR</Name>
<Value> covaliu l</Value>
</variable>-<variable>
<Name>KGH_ALL_SET</Name>
<Value>0</Value>
</variable>-<variable>
<Name>KGH_ALL_REAL</Name>
<Value>0</Value>
</variable>-<variable>
<Name>KGH_F1_SET</Name>
<Value>0</Value>
</variable>-<variable>
<Name>KGH_F1_REAL</Name>
<Value>0</Value>
</variable>-<variable>
<Name>K_F1</Name>
<Value>43</Value>
</variable>-<variable>
<Name>SCREW_RPM_SET</Name>
<Value>550</Value>
</variable>-<variable>
<Name>SCREW_RPM_REAL</Name>
<Value>550.085388183594</Value>
</variable>-<variable>
<Name>TORQUE</Name>
<Value>1.21340000629425</Value>
</variable>-<variable>
<Name>CURRENT</Name>
<Value>60.1959991455078</Value>
</variable>-<variable>
<Name>KW_KG</Name>
<Value>0</Value>
</variable>-<variable>
<Name>KW</Name>
<Value>-0.990000009536743</Value>
</variable>-<variable>
<Name>MELT_PRESSURE</Name>
<Value>0</Value>
</variable>-<variable>
<Name>MELT_TEMPERATURE</Name>
<Value>214</Value>
</variable>-<variable>
<Name>PV1</Name>
<Value>216</Value>
</variable>-<variable>
<Name>SP1</Name>
<Value>210</Value>
</variable>-<variable>
<Name>PV2</Name>
<Value>239</Value>
</variable>-<variable>
<Name>SP2</Name>
<Value>220</Value>
</variable>-<variable>
<Name>PV3</Name>
<Value>220</Value>
</variable>-<variable>
<Name>SP3</Name>
<Value>220</Value>
</variable>-<variable>
<Name>PV4</Name>
<Value>220</Value>
</variable>-<variable>
<Name>SP4</Name>
<Value>220</Value>
</variable>-<variable>
<Name>PV5</Name>
<Value>209</Value>
</variable>-<variable>
<Name>SP5</Name>
<Value>210</Value>
</variable>-<variable>
<Name>PV6</Name>
<Value>210</Value>
</variable>-<variable>
<Name>SP6</Name>
<Value>210</Value>
</variable>-<variable>
<Name>PV7</Name>
<Value>210</Value>
</variable>-<variable>
<Name>SP7</Name>
<Value>210</Value>
</variable>-<variable>
<Name>PV8</Name>
<Value>210</Value>
</variable>-<variable>
<Name>SP8</Name>
<Value>210</Value>
</variable>-<variable>
<Name>PV9</Name>
<Value>210</Value>
</variable>-<variable>
<Name>SP9</Name>
<Value>210</Value>
</variable>-<variable>
<Name>PV10</Name>
<Value>210</Value>
</variable>-<variable>
<Name>SP10</Name>
<Value>210</Value>
</variable>-<variable>
<Name>PV11</Name>
<Value>220</Value>
</variable>-<variable>
<Name>SP11</Name>
<Value>220</Value>
</variable>
</CollectedData>
</recordedData>
Can anyone provide a sample sql script for extracting all the data from it please.
i would really apreciate this since im new to xml.
Thanks in advance.
If you have your data in a table already, you can use something like this:
DECLARE #Tmp TABLE (ID INT NOT NULL, XmlContent XML)
INSERT INTO #TMP VALUES(1, '......(your entire XML here).......)
SELECT
ID,
MACHINE = XmlContent.value('(/recordedData/machine)[1]', 'varchar(50)'),
RecordingDate = XmlContent.value('(/recordedData/date)[1]', 'varchar(50)'),
RecordingTime = XmlContent.value('(/recordedData/hour)[1]', 'varchar(50)'),
VariableName = XVar.value('(Name)[1]', 'varchar(50)'),
VariableValue = XVar.value('(Value)[1]', 'varchar(50)')
FROM
#Tmp
CROSS APPLY
XmlContent.nodes('/recordedData/CollectedData/variable') AS XTbl(XVar)
This gives you an output something like:
.... and so on - listing all the variables with their name and value.

GoogleMaps API 2 displays only 1 innerBoundary LinearRing

I have a .kml-file that exists of a polygon which contains an outerBoundary and an innerBoundary. The innerBoundary contains several LinearRings.
Problem: Only one of these inner LinearRings is displayed. The rest is displayed as one big area. Google Earth displays the .kml correctly. Are there any restrictions regarding the us of linearrings in GoogleMaps?
Here is the .kml-content:
<Polygon>
<tessellate>1</tessellate>
<outerBoundaryIs>
<LinearRing>
<coordinates>
10.34937999738613,52.2400931297914,0 10.35028732773128,52.24063618432182,0 10.35073553354421,52.24136351829702,0 10.35189189716032,52.24988592505383,0 10.34806463125521,52.25774091880214,0 10.35510374802005,52.28074093783913,0 10.36525382191662,52.28219923082257,0 10.36640549564265,52.28254037535547,0 10.36735354160269,52.28335789758861,0 10.3674397722104,52.28435970592113,0 10.36663728719742,52.28523389526337,0 10.36519590745014,52.28570827821546,0 10.36391691384635,52.28570033201087,0 10.3517341349819,52.28394646690337,0 10.35051915642555,52.28350569457596,0 10.34978095205181,52.28276776640299,0 10.17123901924045,52.10131997644089,0 10.17235989643872,52.09780217778586,0 10.18052901452957,52.08985594298313,0 10.18354578384427,52.08079068503564,0 10.18637882641355,52.07734629223897,0 10.18854432497935,52.07383155967357,0 10.18955028947235,52.06494065656974,0 10.18692876383424,52.05806110622614,0 10.18609867783059,52.05526279086962,0 10.18266423770521,52.05031096223487,0 10.17496071867752,52.04209487107367,0 10.17296907566858,52.03952206733667,0 10.17149497660236,52.03721517767351,0 10.13695419788886,52.03180553051456,0 10.11185012314924,52.03039116391627,0 10.09087149418022,52.02383748574601,0 10.06395598483749,52.01658923645414,0 10.04264230747145,52.0219364939592,0 10.04127315628253,52.02206100334206,0 9.993582127634355,52.01377847086962,0 9.992518659595907,52.01343413056657,0 9.973070143149375,52.00223345088979,0 9.972452351144421,52.00145279897677,0 9.971465164608219,51.99723807014183,0 9.971729956811503,51.99619487354173,0 9.982781094375952,51.98230833589174,0 9.98584776903783,51.97767128379079,0 9.992498747079996,51.96927237388741,0 9.991526824755352,51.96658410520506,0 9.989677102727526,51.963473925892,0 9.989207353193477,51.95269115440273,0 9.987723808375995,51.94759969646137,0 9.988071290637597,51.94503958871096,0 9.985579149150164,51.92797935885888,0 9.982634581314299,51.92083011116905,0 9.976545113382445,51.91358003449792,0 9.976425347410789,51.91292134538674,0 9.977126572252928,51.90983485754025,0 9.976952152650551,51.9091575821778,0 9.968953361244287,51.90072768735519,0 9.967557385574938,51.89664429777992,0 9.956519186614326,51.89479325501542,0 9.925661213733045,51.88279570915655,0 9.904634577687874,51.87420986179821,0 9.866042836600235,51.87400563077158,0 9.840786680672371,51.86905472152661,0 9.824203687168184,51.86773721822254,0 9.82298684359637,51.86725725891039,0 9.818088684867986,51.86401828583837,0 9.817515015321169,51.86346138336545,0 9.817307929193369,51.86270312498086,0 9.817553956020044,51.86206040887191,0 9.833358727419491,51.83999817325148,0 9.825588568423228,51.82959855222769,0 9.825387811138562,51.82897746283462,0 9.825495834546105,51.82845301933803,0 9.83486681570386,51.80801887912119,0 9.835632705182052,51.80746767536245,0 9.849580942970656,51.80080950671429,0 9.849600167988919,51.78724427692575,0 9.849876463783591,51.78647980124794,0 9.859745265032096,51.77703207261995,0 9.860798037692216,51.77663908436064,0 9.869772750268464,51.77511146307911,0 9.876676533814441,51.75968297256625,0 9.885545467658448,51.75040513318897,0 910.25515643681103,52.19397075429494,0 10.26135026990052,52.21132679490286,0 10.26963559455321,52.23086057113682,0 10.28947890832842,52.23815799379152,0 10.30985734418318,52.23906966294749,0 10.33729401671664,52.23517167118531,0 10.33877755468816,52.23549639900235,0 10.34937999738613,52.2400931297914,0
</coordinates>
</LinearRing>
</outerBoundaryIs>
<innerBoundaryIs>
<LinearRing>
<coordinates>
10.27240821061489,52.23739156394223,0 10.2764943557397,52.23757524856065,0 10.27174445694194,52.23582825416547,0 10.27240821061489,52.23739156394223,0
</coordinates>
</LinearRing>
<LinearRing>
<coordinates>
10.18590478472491,52.15184617814074,0 10.18773321261526,52.15414275375152,0 10.21854744180636,52.15686432790342,0 10.23586289911141,52.1616131675119,0 10.22852565174004,52.13471903003445,0 10.19907268145813,52.12880881157728,0 10.19802803146131,52.12843785325227,0 10.19729603908177,52.12787129612924,0 10.18590478472491,52.15184617814074,0
</coordinates>
</LinearRing>
<LinearRing>
<coordinates>
10.23187520742232,52.13160858695364,0 10.23571535283616,52.1236867447657,0 10.22667121522805,52.11881744802448,0 10.22109857567036,52.11870933547221,0 10.21078352155337,52.11987259654627,0 10.20429452469993,52.11868770269162,0 10.20327487665741,52.11836177245213,0 10.19905835436177,52.11820259075669,0 10.190985760793,52.11586553708817,0 10.20182609048271,52.1255791563385,0 10.23187520742232,52.13160858695364,0
</coordinates>
</LinearRing>
<LinearRing>
<coordinates>
10.11354864384782,52.02691666973372,0 10.13151211051896,52.02789850744416,0 10.12545920096105,52.02250120742188,0 10.12115370440896,52.02306613120236,0 10.11409090517594,52.02619009189071,0 10.11284926571018,52.02631832329674,0 10.1110575406069,52.02613565645892,0 10.11354864384782,52.02691666973372,0
</coordinates>
</LinearRing>
<LinearRing>
<coordinates>
10.06289843475212,52.01297237953833,0 10.06368688114465,52.01285424011538,0 10.04400246521565,52.00488379991821,0 10.0351964323982,52.00571428303371,0 10.02573814759202,52.01564941803622,0 10.04137389856296,52.01837271512394,0 10.06289843475212,52.01297237953833,0
</coordinates>
</LinearRing>
<LinearRing>
<coordinates>
10.01882301837729,52.00560126467275,0 10.01791689653521,52.00539276971088,0 10.0050253272684,52.00079801438069,0 9.993875665300854,52.00228244268756,0 9.992134598533912,52.00211352869745,0 9.991166239402519,52.0016318487105,0 9.981427080384554,51.99415622397375,0 9.980941046720865,51.99361138063993,0 9.980759989325868,51.99296427637764,0 9.977359126595832,51.99727356538052,0 9.978038861895602,52.00019420582686,0 9.995846263268103,52.01043639671395,0 10.01994043853371,52.01463901100602,0 10.02777237895539,52.00641389910906,0 10.02626864279406,52.00648239580418,0 10.01882301837729,52.00560126467275,0
</coordinates>
</LinearRing>
<LinearRing>
<coordinates>
9.855380456437191,51.80169632950742,0 9.855119830069164,51.80243987247973,0 9.854386518894319,51.80305001931052,0 9.839933854203153,51.80995371744533,0 9.831373766045314,51.82878797008037,0 9.839179683205527,51.83922597534188,0 9.839404889927408,51.84029323311771,0 9.823643881550311,51.86242988789854,0 9.826509623369027,51.86432475842264,0 9.842197864125474,51.86555988217815,0 9.86704471096979,51.87044292628841,0 9.905536620020534,51.87061742660831,0 9.906519913254138,51.87072815252332,0 9.928781226163636,51.8797617050511,0 9.959037904887037,51.8915342064961,0 9.968869728798218,51.89293046686156,0 9.977083330120085,51.88675718741706,0 9.982655907636911,51.87820649720261,0 9.984272976389917,51.87138278467505,0 9.983651533434161,51.85353399457469,0 9.987777500110123,51.84763608560537,0 9.981469536990044,51.83274288936134,0 9.970816392727089,51.82703158241299,0 9.956599412741996,51.82907323582232,0 9.95556264347865,51.82910399548598,0 9.921872620678796,51.82237194577901,0 9.91192480770844,51.81694106337533,0 9.906156124476002,51.8115227738887,0 9.891257184341672,51.80867361904743,0 9.890034393182011,51.80820991397683,0 9.889319119927114,51.807439865585,0 9.885811775837659,51.79966617047114,0 9.855391699864116,51.79296879392769,0 9.855380456437191,51.80169632950742,0
</coordinates>
</LinearRing>
<LinearRing>
<coordinates>
9.86890429376237,51.56354064617938,0 9.869030672132483,51.56708858502184,0 9.868739939008581,51.56780390095923,0 9.864784413676471,51.57056411969143,0 9.863623326635489,51.57115133822988,0 9.859453426883198,51.57483294787452,0 9.857515482579942,51.57850038260351,0 9.854428559135329,51.58106661061861,0 9.854252288034655,51.58298572132568,0 9.854895336189246,51.58473451977891,0 9.862212841963995,51.58982159226014,0 9.869241814810382,51.59244554094607,0 9.871322234564712,51.59363072034962,0 9.881935043226713,51.59871541941715,0 9.882379358832242,51.59929699309934,0 9.88247756305641,51.59983109680827,0 9.881520913538093,51.60604789848786,0 9.889613646059484,51.60130694440697,0 9.890409141381278,51.60108256234895,0 9.895450994668202,51.60040068385107,0 9.903592019914388,51.58728320641903,0 9.905330178839382,51.58167615977795,0 9.907553200849135,51.57969162398687,0 9.906820366259776,51.57871151051718,0 9.903677729334847,51.57595210076617,0 9.89527402192472,51.57357473795214,0 9.890584872936334,51.57287177975935,0 9.881911674694724,51.57035699151297,0 9.876371843174104,51.5656654651476,0 9.869032158747784,51.56107768324107,0 9.86890429376237,51.56354064617938,0
</coordinates>
</LinearRing>
<LinearRing>
<coordinates>
9.858779201867323,51.489395786305,0 9.864489621937006,51.49867993563625,0 9.867794245523871,51.50340826526058,0 9.873584684187492,51.50883719711155,0 9.874053245703335,51.50967352043285,0 9.873661828012333,51.51074709140966,0 9.871227066916033,51.51264459741823,0 9.865199822266186,51.51417715492575,0 9.860955086576029,51.51640833776862,0 9.859908629441906,51.51873811374746,0 9.858468178311505,51.52096647345068,0 9.857525214583614,51.52373210290834,0 9.857597510748208,51.52418686355039,0 9.859765327686237,51.52715272740425,0 9.862434541871872,51.52767629364014,0 9.865614757326281,51.52852504614184,0 9.866547487939497,51.52789349828291,0 9.867468358529136,51.52755548402293,0 9.874764845725821,51.52679006687561,0 9.875325767065272,51.52638134145568,0 9.874926368670787,51.51820657572394,0 9.87474063387136,51.51651984620041,0 9.874312502754096,51.51545187268457,0 9.874780795333292,51.51327638972658,0 9.874456985777195,51.50921250576209,0 9.874581338154602,51.50603829350691,0 9.873712838338808,51.50455994136525,0 9.873450923529427,51.50306920869146,0 9.873930297392372,51.50181147980375,0 9.875310793678436,51.50076032424005,0 9.881753757897126,51.49869972684076,0 9.880761486319919,51.49754595564943,0 9.88072183859919,51.49684654347324,0 9.881192794667367,51.49523214943569,0 9.876509719819918,51.47837031946511,0 9.850701464793442,51.47583322928328,0 9.847810692240678,51.47478923336729,0 9.858779201867323,51.489395786305,0
</coordinates>
</LinearRing>
<LinearRing>
<coordinates>
9.700915364420565,51.39833473774542,0 9.704760900917059,51.40249573430605,0 9.717216014224352,51.40815082334107,0 9.726732623236611,51.4074530351857,0 9.722770449280167,51.40476707154078,0 9.720262729350688,51.40032684898068,0 9.710957776498663,51.39567950127049,0 9.709086330617494,51.39579774654011,0 9.707890707395132,51.39562598075706,0 9.705084177996804,51.39438960270704,0 9.70354585738661,51.39348123887451,0 9.700915364420565,51.39833473774542,0
</coordinates>
</LinearRing>
<LinearRing>
<coordinates>
9.698936529761641,51.39078538267555,0 9.677762021304144,51.3787958120418,0 9.677008755773104,51.38211581122835,0 9.682988923925883,51.39053067020733,0 9.693828612498157,51.39614277114144,0 9.695244796747653,51.39759564779137,0 9.698936529761641,51.39078538267555,0
</coordinates>
</LinearRing>
<LinearRing>
<coordinates>
9.522034625765256,51.22259437450317,0 9.522979205800814,51.22370380330301,0 9.52768334312384,51.22746450172978,0 9.53635605519032,51.21216414973087,0 9.525539137183376,51.18814702076687,0 9.525399410194455,51.18823971302789,0 9.527310124965183,51.19501998921333,0 9.528298630294144,51.2057504581035,0 9.53204252703279,51.20828155732802,0 9.532498594287013,51.20889328602176,0 9.53258073147564,51.20945485152588,0 9.532213525360746,51.21290572972887,0 9.531910321718831,51.21351406586848,0 9.522034625765256,51.22259437450317,0
</coordinates>
</LinearRing>
<LinearRing>
<coordinates>
9.526567184112189,51.21207137148459,0 9.526785168010123,51.20999667128658,0 9.523291568868128,51.20764874799909,0 9.522685878292876,51.20683386405892,0 9.521605113535721,51.195334894947,0 9.520211295082605,51.19043984922755,0 9.510266683134566,51.19385765700603,0 9.509463336935815,51.1968992424458,0 9.501356257893827,51.20709698936993,0 9.502119168542613,51.21478809659912,0 9.512304662533206,51.21897404368077,0 9.518206492157084,51.21973903684739,0 9.526567184112189,51.21207137148459,0
</coordinates>
</LinearRing>
<LinearRing>
<coordinates>
9.566525360512614,50.95188995013688,0 9.565479242591346,50.95449309176134,0 9.564802800709609,50.96003377443925,0 9.567534207392471,50.96226322842058,0 9.569698398842194,50.96456983453521,0 9.575536280129162,50.96928088347298,0 9.576055653035635,50.96995108744741,0 9.576277222243927,50.98296415481611,0 9.579364036175264,50.99277703000576,0 9.582533132190738,50.99138605706582,0 9.584352635304223,50.98904585067294,0 9.58581067352212,50.98790619940409,0 9.596392328911248,50.98394786818935,0 9.598667153104369,50.9821897573667,0 9.603232195633218,50.97945012627671,0 9.614428236192232,50.97561718875059,0 9.644160337633387,50.96635515847068,0 9.65028951030282,50.96171054751159,0 9.654237948243322,50.95754130345146,0 9.657791683275045,50.95480841775315,0 9.658940270915299,50.95208128446779,0 9.661390326838658,50.94728570709903,0 9.666505042348,50.94150469916001,0 9.65936931086183,50.93930120802193,0 9.640094527498892,50.93882642485261,0 9.635736252370434,50.93973613853624,0 9.610687192073122,50.94005363827884,0 9.59376008313339,50.94328774217297,0 9.582192203629981,50.94160152758662,0 9.577345136066558,50.9453347954319,0 9.574690150351453,50.94820249070614,0 9.566525360512614,50.95188995013688,0
</coordinates>
</LinearRing>
<LinearRing>
<coordinates>
9.691035727400973,50.94291153857649,0 9.689766324329076,50.94351462196823,0 9.688500981213201,50.94388586575064,0 9.683879870931593,50.94453884540298,0 9.679208397988028,50.94685105621964,0 9.677416907750475,50.94752801006935,0 9.674552236791667,50.95076797113131,0 9.67255599884742,50.9547103928351,0 9.671032377865732,50.9583296873603,0 9.670467991921349,50.95913579865325,0 9.666016990148759,50.96261560124843,0 9.661791337571643,50.96703634982091,0 9.655006719562683,50.97218451816755,0 9.651705894600344,50.97792265148249,0 9.693756857659995,50.96115383024377,0 9.692363174997794,50.94211981725465,0 9.691035727400973,50.94291153857649,0
</coordinates>
</LinearRing>
<LinearRing>
<coordinates>
9.705487811251786,50.950975535479,0 9.738264711641767,50.92250707407628,0 9.737719884122978,50.91949528507026,0 9.732327895099079,50.92016993985099,0 9.704071088296358,50.93243878579288,0 9.705487811251786,50.950975535479,0
</coordinates>
</LinearRing>
<LinearRing>
<coordinates>
9.57297933239772,50.9401935460989,0 9.568953345788223,50.9399725935024,0 9.556408846647523,50.94562492276181,0 9.558357888420554,50.95029368366789,0 9.558936040330554,50.94908033246935,0 9.55982348096966,50.94831011477817,0 9.568323611436394,50.94450353082688,0 9.570261536638659,50.94230436055462,0 9.57297933239772,50.9401935460989,0
</coordinates>
</LinearRing>
</innerBoundaryIs>
</Polygon>
I checked out the integrity of your kml file. There are a couple of problems:
The xsi prefix declaration is missing:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
Once I added that, the Galdos KML validator was able to process the file.
Here's what it told me:
cvc-complex-type.2.4.a: Invalid content was found starting with element 'LinearRing'. One of '{"http://www.opengis.net/kml/2.2":BoundarySimpleExtensionGroup, "http://www.opengis.net/kml/2.2":BoundaryObjectExtensionGroup}' is expected.
(My desktop XML validator issued the same complaint.)
The problem is that <kml:innerBoundaryIs> contains multiple <kml:LinearRing> elements.
Then, checking the KML Reference for <kml:innerBoundaryIs> I found this:
Contains a <LinearRing> element. A Polygon can contain multiple <innerBoundaryIs>
elements, which create multiple cut-outs inside the Polygon.
So, it appears that Google Earth may be tolerant of your malformed KML, but perhaps Google Maps is not.
Possible solution: Instead of repeating <kml:LinearRing> within <kml:innerBoundaryIs>, try repeating <kml:innerBoundaryIs> within <kml:Polygon>.
Looks to me like the LinearRing polylines are crossing themselves.
http://www.geocodezip.com/geoxml3_test/v3_geoxml3_kmltest_winding_linkto.html?lat=52.051462&lng=10.031042&zoom=9&type=m&filename=http://www.geocodezip.com/geoxml3_test/testkml_polygon_inner_kml.xml
There is some character encoding issue which makes the chrome browser fail on the kml, but that doesn't seem to be the problem.
It looks like a problem with the Google Maps KML renderer (although I suppose it could be a problem with the KML), geoxml3 renders it correctly, but KmlLayer does not:
http://www.geocodezip.com/geoxml3_test/v3_geoxml3_kmltest_winding_linkto.html?lat=52.051462&lng=10.031042&zoom=9&type=m&filename=http://www.geocodezip.com/geoxml3_test/neustekarteA_kml.xml
Google Maps renders it the same as KmlLayer:
There are limitations on Google Maps, but it doesn't look like you are running in to them.
Probably should open an issue against the KML renderer