asp.netでxmlファイルをロードするプロジェクトを作成しています
xml ファイルの 1 つに質問があり、別の質問で画像とフラッシュを表示したいと考えています。
<![CDATA[<a><img src="Study/1.png"/><a>]]>
それは私がxmlで使用しているコードです。私の問題は、フラッシュコンテンツと画像の両方を正常に表示することですが、cdataプロパティを閉じていません.
]]> 画像やオブジェクトの直後。
何か案は?
ここに私のxmlがあります
<?xml version="1.0" encoding="UTF-8"?>
<quiz xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="quiz.xsd">
<mchoice>
<question>For aircraft flying over the high seas, which rules shall be in force? <![CDATA[<a><img src="Study/1.png"/></a>]]></question>
<answer>The rules established by the state(s) adjacent to the high seas over flown </answer>
<answer>The rules established by the state of the operator of the aircraft </answer>
<answer correct="yes">The rules established by the state of registry of the aircraft </answer>
<answer>The rules established under the Convention of international civil aviation </answer>
</mchoice>
</quiz>
ここに私のスキーマがあります
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="quiz">
<xs:complexType>
<xs:choice>
<xs:element name="mchoice" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="question" type="xs:string"/>
<xs:element name="answer" minOccurs="2" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="correct" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="yes"/>
<xs:enumeration value="no"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
これがxmlのasp.netコードです
Public Shared Function GetQuizDataFromXML(ByVal XMLFileName As String) As ArrayList
Dim strXmlFilePath As String = XMLFileName
Dim xDoc As XmlDocument = New XmlDocument()
xDoc.Load(strXmlFilePath)
Dim Arl As New ArrayList
If Not IsNothing(xDoc) AndAlso xDoc.SelectNodes("/quiz/mchoice").Count > 0 Then
Dim TotalQuestions As Integer = 0
TotalQuestions = xDoc.SelectNodes("/quiz/mchoice").Count
For i As Integer = 1 To TotalQuestions
Dim strXPath As String = ""
strXPath = "/quiz/mchoice[" & i.ToString() & "]"
Dim oQ As New Questions
oQ.QuestionID = i + 1
oQ.Question = xDoc.SelectSingleNode(strXPath & "/question").InnerXml
Dim xNodeList As XmlNodeList
xNodeList = xDoc.SelectNodes(strXPath & "/answer")
For j As Integer = 0 To xNodeList.Count - 1
Dim oA As New Answers
oA.QuestionID = oQ.QuestionID
oA.Answer = xNodeList.Item(j).InnerText
oA.AnswerID = j + 1
Dim xNodeAttr As Object
'Extract correct answer
xNodeAttr = xNodeList.Item(j).Attributes.ItemOf("correct")
oA.IsAnswer = False
If Not xNodeAttr Is Nothing Then
If xNodeAttr.Value = "yes" Then
oA.IsAnswer = True
End If
End If
oQ.Answers.Add(oA)
Next
Arl.Add(oQ)
Next
End If
Return Arl
End Function