4

XSD.exe を使用すると、XSD ファイルから C# または VB.NET クラスを簡単に派生させることができます。XSD を JavaScript に変換するツールはありますか?

4

1 に答える 1

5
  • 試してくださいxsd /language:JS(ここを参照)。

  • Jsonixを試してください。

免責事項:私は、XML<->JS 変換用のオープンソース ライブラリであるJsonixの作成者です。

Jsonix を使用すると、スキーマを JavaScript マッピングにコンパイルしてから、JavaScript コードで XML をマーシャリング/アンマーシャリングできます。次に例を示します。

// First we construct a Jsonix context - a factory for unmarshaller (parser)
// and marshaller (serializer)
var context = new Jsonix.Context([ PO ]);

// Then we create an unmarshaller
var unmarshaller = context.createUnmarshaller();

// Unmarshal an object from the XML retrieved from the URL
unmarshaller.unmarshalURL('/org/hisrc/jsonix/samples/po/test/po-0.xml',
    // This callback function will be provided with the result
    // of the unmarshalling
    function(result) {
        // We just check that we get the values we expect
        assertEquals('Alice Smith', result.value.shipTo.name);
        assertEquals('Baby Monitor', result.value.item[1].productName);
    });
于 2011-06-10T16:39:53.567 に答える