我正在尝试解析XML文档以获取用户输入的变量并将这些变量保存为swift中的变量。我在网上看到的例子使用带有硬编码值的NSXMLParser。
您如何解析用户输入的变量?以下是我需要解析的变量示例:
编辑:类似于Watson Dialog XML
<folder label="Main">
<output>
<prompt selectionType="RANDOM">
<item>Hello, welcome to Mike’s Pizza what keywords do you want</item>
</prompt>
<goto ref="getUserInput_2449614"/>
</output>
<getUserInput id="getUserInput_2449614">
<search ref="folder_2449611"/>
<default>
<output>
<prompt selectionType="RANDOM">
<item>I am sorry, I did not understand your question. Please try asking another one.</item>
</prompt>
</output>
</default>
</getUserInput>
</folder>
<folder label="Library">
<folder label="Live Content" id="folder_2449611">
<input>
<grammar>
<item>What type of keywords do you have?</item>
<item>$ What type of keywords do you have?</item>
<item>$ list of keywords</item>
<item>What * keywords * have</item>
<item>$ list keywords * available</item>
<item>$ what keywords do you have</item>
</grammar>
<output>
<prompt selectionType="RANDOM">
<item>We have Pepperoni, Mushrooms, and Sausage</item>
</prompt>
<getUserInput>
<input id="userInput" type="TEXT">
<grammar>
<item>*</item>
</grammar>
<output>
<prompt/>
<action varName="topping" operator="SET_TO_USER_INPUT"/>
<output>
<prompt>
<item>you just ordered this topping: {topping}</item>
</prompt>
</output>
</output>
</input>
</getUserInput>
</output>
</input>
</folder>
</folder>
<constants>
<var_folder name="Home"/>
</constants>
<variables>
<var_folder name="Home">
<var id="topping" name="topping" type="TEXT"/>
</var_folder>
</variables>