은 내가 XmlSerializer를를 사용하여 다음 XML (조각)를 역 직렬화하기 위해 노력하고있어 http://www.bonnland.de/FIBEX.zip.NET, XmlSerializer InvalidOperationException, XmlSchema 정의로 인해?
에 XML 파일 내가 읽은려고하고 해당 XSD 파일을 모두 포함하는 ZIP 파일을 업로드했습니다. 그렇게하는 동안 나는 오류를 얻을 :이 같은 무언가로 변환
System.InvalidOperationException==>Fehler im XML-Dokument (90,7). System.InvalidOperationException==>Der angegebene Typ wurde nicht erkannt: Name='CONTROLLER-TYPE', Namespace='http://www.asam.net/xml/fbx/can', bei .
(그것이 내가 이탤릭체에 거친 번역을주지 독일어 것에 대해 죄송합니다) : 여기
System.InvalidOperationException==>error in XML document (90,7). System.InvalidOperationException==>the given type could not be found: Name='CONTROLLER-TYPE', Namespace='http://www.asam.net/xml/fbx/can', at
하면 원본 문서의 :
<fx:ECU ID="ecuSpeedControl">
<ho:SHORT-NAME>SpeedControl</ho:SHORT-NAME>
<ho:DESC>ECU controlling drive speed</ho:DESC>
<fx:CONTROLLERS>
<fx:CONTROLLER xsi:type="can:CONTROLLER-TYPE" ID="ctrlSpeedControl">
<ho:SHORT-NAME>ctrlSpeedControl</ho:SHORT-NAME>
<ho:DESC>CAN controller of ECU</ho:DESC>
<fx:CHIP-NAME>SJA1000</fx:CHIP-NAME>
<can:TIME-SEG0>11</can:TIME-SEG0>
<can:TIME-SEG1>4</can:TIME-SEG1>
<can:SYNC-JUMP-WIDTH>2</can:SYNC-JUMP-WIDTH>
<can:NUMBER-OF-SAMPLES>1</can:NUMBER-OF-SAMPLES>
</fx:CONTROLLER>
</fx:CONTROLLERS>
</fx:ECU>
루트 요소는 다음과 같습니다
<fx:FIBEX xmlns:fx="http://www.asam.net/xml/fbx" xmlns:ho="http://www.asam.net/xml"
xmlns:can="http://www.asam.net/xml/fbx/can" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="fibex4can.xsd" VERSION="3.1.0">
이 조각의 클래스 정의는 다음과 같습니다
public ref class FIBEXECU : AbstractFIBEXNode, IGenericContainable
{
public:
ref class ControllersContainer : FIBEXGenericContainer<FIBEXController^>{
public:
[XmlElement("CONTROLLER")]
property array<FIBEXController^>^ ControllerObjs {
array<FIBEXController^>^ get() { return Children;}
void set(array<FIBEXController^>^ value) { Children = value;}
}
};
[XmlAttribute("ID")]
virtual property String^ ID;
[XmlElement("SHORT-NAME", Namespace="http://www.asam.net/xml")]
property String^ ShortName;
[XmlElement("CONTROLLERS")]
property ControllersContainer^ Controllers;
};
것은 내가 (다시 한번) 사람이 내가 여기에 구글이나에 대한 해결책을 찾을 수 없습니다로, 나를 도울 수 있기를 바랍니다.
'XmlSerializer'를 사용하여 하드 루트를 가져 오는 이유는 무엇입니까? 유형이 일치하지 않는다는 사실은 XML을 작성하기 위해 유형이 처음에는 사용되지 않았다는 느낌을줍니다. 이 경우 일반적으로 XmlReader, XDocument (LINQ는 C++에서는 쉽지 않음) 또는 XmlDocument와 같은 기존 처리 방법을 사용하는 것이 더 빠르고 쉽습니다. – Abel
좋은 질문입니다. 솔직히 솔직히 말하면 나는 XmlDocument에 대해서도 생각조차하지 않았다. (나는 방금 그렇게하지 않았다 :-(). 당신은 타입이 XML을 만드는 데 사용되지 않았다는 점에서 옳다. 나는 리버스 엔지니어링의 일종을 여기에서하고있다 .. – yas4891