是否可以将JSON文件转换为XML以在WordPress中导入?
我已经使用网络刮擦来在互联网上进行测验。 我想在WordPress上导入它们,
这是一个XML文件的示例,该XML文件已从WordPress
<?xml version="1.0" encoding="utf-8"?>
<wpProQuiz><header version="0.28" exportVersion="1" ld_version="4.1.2" LEARNDASH_SETTINGS_DB_VERSION="2.5"/><data><quiz><title titleHidden="true"><![CDATA[PSPO Exam Blanc #4 (with comments)]]></title><text><![CDATA[ AAZZAAZZ]]></text><resultText gradeEnabled="true"><text prozent="0"><![CDATA[]]></text></resultText><btnRestartQuizHidden>false</btnRestartQuizHidden><btnViewQuestionHidden>false</btnViewQuestionHidden><questionRandom>false</questionRandom><answerRandom>false</answerRandom><timeLimit>0</timeLimit><showPoints>false</showPoints><statistic activated="true" ipLock="0"/><quizRunOnce type="0" cookie="false" time="0">false</quizRunOnce><numberedAnswer>false</numberedAnswer><hideAnswerMessageBox>false</hideAnswerMessageBox><disabledAnswerMark>false</disabledAnswerMark><showMaxQuestion showMaxQuestionValue="0" showMaxQuestionPercent="false">false</showMaxQuestion><toplist activated="false"><toplistDataAddPermissions>1</toplistDataAddPermissions><toplistDataSort>1</toplistDataSort><toplistDataAddMultiple>false</toplistDataAddMultiple><toplistDataAddBlock>0</toplistDataAddBlock><toplistDataShowLimit>0</toplistDataShowLimit><toplistDataShowIn>0</toplistDataShowIn><toplistDataCaptcha>false</toplistDataCaptcha><toplistDataAddAutomatic>false</toplistDataAddAutomatic></toplist><showAverageResult>false</showAverageResult><prerequisite>false</prerequisite><showReviewQuestion>true</showReviewQuestion><quizSummaryHide>true</quizSummaryHide><skipQuestionDisabled>true</skipQuestionDisabled><emailNotification>0</emailNotification><userEmailNotification>false</userEmailNotification><showCategoryScore>false</showCategoryScore><hideResultCorrectQuestion>false</hideResultCorrectQuestion><hideResultQuizTime>false</hideResultQuizTime><hideResultPoints>false</hideResultPoints><autostart>false</autostart><forcingQuestionSolve>false</forcingQuestionSolve><hideQuestionPositionOverview>true</hideQuestionPositionOverview><hideQuestionNumbering>true</hideQuestionNumbering><sortCategories>false</sortCategories><showCategory>false</showCategory><quizModus questionsPerPage="0">2</quizModus><startOnlyRegisteredUser>true</startOnlyRegisteredUser><forms activated="false" position="0"/><questions><question answerType="single"><title>
<![CDATA[Question 1]]></title><points>1</points><questionText><![CDATA[<p>What provides guidance to the Developers on why they are building the Increment?<br />(choose the best answer)</p>]]></questionText><correctMsg><![CDATA[<p>The Sprint Goal is an objective set for the Sprint that can be met through the implementation of Product Backlog. It provides guidance to the Scrum Team on why it is building the Increment.</p>]]></correctMsg><incorrectMsg><![CDATA[<p>The Sprint Goal is an objective set for the Sprint that can be met through the implementation of Product Backlog. It provides guidance to the Scrum Team on why it is building the Increment.</p>]]></incorrectMsg><tipMsg enabled="false"><![CDATA[]]></tipMsg><category/><correctSameText>true</correctSameText><showPointsInBox>false</showPointsInBox><answerPointsActivated>false</answerPointsActivated><answerPointsDiffModusActivated>false</answerPointsDiffModusActivated><disableCorrect>false</disableCorrect><answers><answer points="1" correct="true"><answerText html="false"><![CDATA[The Sprint Goal]]></answerText><stortText html="false"><![CDATA[]]></stortText></answer><answer points="0" correct="false"><answerText html="false"><![CDATA[The Product Owner]]></answerText><stortText html="false"><![CDATA[]]></stortText></answer><answer points="0" correct="false"><answerText html="false"><![CDATA[The Scrum Master]]></answerText><stortText html="false"><![CDATA[]]></stortText></answer><answer points="0" correct="false"><answerText html="false"><![CDATA[The Sprint Backlog]]></answerText><stortText html="false"><![CDATA[]]></stortText></answer></answers></question><question answerType="single"><title>
<![CDATA[Question 2]]></title><points>1</points><questionText><![CDATA[<p>How long does a Product Backlog exists?<br />(choose the best answer)</p>]]></questionText><correctMsg><![CDATA[<p>The Product Backlog is dynamic; it constantly changes to identify what the product needs to be appropriate, competitive, and useful. If a product exists, its Product Backlog also exists.</p>]]></correctMsg><incorrectMsg><![CDATA[<p>The Product Backlog is dynamic; it constantly changes to identify what the product needs to be appropriate, competitive, and useful. If a product exists, its Product Backlog also exists.</p>]]></incorrectMsg><tipMsg enabled="false"><![CDATA[]]></tipMsg><category/><correctSameText>true</correctSameText><showPointsInBox>false</showPointsInBox><answerPointsActivated>false</answerPointsActivated><answerPointsDiffModusActivated>false</answerPointsDiffModusActivated><disableCorrect>false</disableCorrect><answers><answer points="1" correct="true"><answerText html="false"><![CDATA[As long as the Product exists.]]></answerText><stortText html="false"><![CDATA[]]></stortText></answer><answer points="0" correct="false"><answerText html="false"><![CDATA[Until the final Product Release.]]></answerText><stortText html="false"><![CDATA[]]></stortText></answer><answer points="0" correct="false"><answerText html="false"><![CDATA[Not more than 3 years.]]></answerText><stortText html="false"><![CDATA[]]></stortText></answer><answer points="0" correct="false"><answerText html="false"><![CDATA[As long as a Developer is doing work from it.]]></answerText><stortText html="false"><![CDATA[]]></stortText></answer></answers></question><question answerType="single"><title>
<![CDATA[Question 3]]></title><points>1</points><questionText><![CDATA[<p>Peter has been asked to take the Product Owner role of a large<br />product initiative. 4 teams new to Scrum will be building this product. He has created the initial Product Backlog but is unsure of how to minimize the dependencies between the Scrum Teams.<br />Which of the following would be the best advice to give Peter?<br />(choose the best answer)</p>]]></questionText><correctMsg><![CDATA[<p>Because the Developers are the ones doing the work, they would be the best ones to help the Product Owner analyze and reduce the dependencies between the work to be done.</p>]]></correctMsg><incorrectMsg><![CDATA[<p>Because the Developers are the ones doing the work, they would be the best ones to help the Product Owner analyze and reduce the dependencies between the work to be done.</p>]]></incorrectMsg><tipMsg enabled="false"><![CDATA[]]></tipMsg><category/><correctSameText>true</correctSameText><showPointsInBox>false</showPointsInBox><answerPointsActivated>false</answerPointsActivated><answerPointsDiffModusActivated>false</answerPointsDiffModusActivated><disableCorrect>false</disableCorrect><answers><answer points="1" correct="false"><answerText html="false"><![CDATA[The Product Owner creates separate Product Backlogs for each team.]]></answerText><stortText html="false"><![CDATA[]]></stortText></answer><answer points="0" correct="false"><answerText html="false"><![CDATA[The Product Owner identifies the dependent items and re-order the Product Backlog items for the Scrum Teams.]]></answerText><stortText html="false"><![CDATA[]]></stortText></answer><answer points="0" correct="true"><answerText html="false"><![CDATA[The Product Owner works with the Developers from all Scrum Teams on how to best analyze and break apart the work.]]></answerText><stortText html="false"><![CDATA[]]></stortText></answer><answer points="0" correct="false"><answerText html="false"><![CDATA[The Product Owner has the Technical Leads determine which items will be assigned to which team.]]></answerText><stortText html="false"><![CDATA[]]></stortText></answer><answer points="0" correct="false"><answerText html="false"><![CDATA[The Product Owner notifies the Scrum Master so he/she can resolve the impediment.]]></answerText><stortText html="false"><![CDATA[]]></stortText></answer></answers></question><question answerType="single"><title>
<![CDATA[Question 4]]>
和JSON文件导出,看起来像这样:
[
{
"question": "Who supports the Scrum Master in removing impediments?\n(choose the best three answers)\nChoose ALL answers that apply.",
"correct": [
"Management",
"The Product Owner",
"The Developers"
],
"incorrect": [
"The customer"
],
"explic": "The Developers can help the Scrum Master because of their understanding of how the work is done and their internal interactions with each other. Some impediments are rooted in external causes and that's why the Scrum Master might need to have the senior management's support in removing them. The Product Owner can also support the Scrum Master by managing stakeholder expectations."
},
{
"question": "Which TWO of the following statements are true?\n(choose the best two answers)\nChoose ALL answers that apply.",
"correct": [
"Early feedback enables agile teams to deliver features with the highest business value first, because the customer maintains focus on features with the highest system value.",
"Early feedback makes it more likely that the system built is what the customer wanted because they are given the opportunity to make changes throughout the iteration."
],
"incorrect": [
"Early feedback reduces costs because it decreases the amount of time needed for system testing.",
"Early feedback gives the Developers more time to develop new system features because they spend less time reworking features expected in a given iteration."
],
"explic": "Agile teams are highly flexible and adaptive. These strengths continue operating in single, several, many, and networks of teams that develop, release, operate and sustain the work and work products of thousands of people. They collaborate and interoperate with team members and stakeholders in order to maximize opportunities of success."
}
]
因此,在这种情况下,我只能导入XML文件,我想我应该转换此信息XML中的JSON文件,但我不知道是否可能,如果是,请问您有一个主意吗?
I have used web scraping to get quiz on internet.
And I want to import them on wordpress
Here's an example of a piece of an XML file that has been exported from Wordpress
<?xml version="1.0" encoding="utf-8"?>
<wpProQuiz><header version="0.28" exportVersion="1" ld_version="4.1.2" LEARNDASH_SETTINGS_DB_VERSION="2.5"/><data><quiz><title titleHidden="true"><![CDATA[PSPO Exam Blanc #4 (with comments)]]></title><text><![CDATA[ AAZZAAZZ]]></text><resultText gradeEnabled="true"><text prozent="0"><![CDATA[]]></text></resultText><btnRestartQuizHidden>false</btnRestartQuizHidden><btnViewQuestionHidden>false</btnViewQuestionHidden><questionRandom>false</questionRandom><answerRandom>false</answerRandom><timeLimit>0</timeLimit><showPoints>false</showPoints><statistic activated="true" ipLock="0"/><quizRunOnce type="0" cookie="false" time="0">false</quizRunOnce><numberedAnswer>false</numberedAnswer><hideAnswerMessageBox>false</hideAnswerMessageBox><disabledAnswerMark>false</disabledAnswerMark><showMaxQuestion showMaxQuestionValue="0" showMaxQuestionPercent="false">false</showMaxQuestion><toplist activated="false"><toplistDataAddPermissions>1</toplistDataAddPermissions><toplistDataSort>1</toplistDataSort><toplistDataAddMultiple>false</toplistDataAddMultiple><toplistDataAddBlock>0</toplistDataAddBlock><toplistDataShowLimit>0</toplistDataShowLimit><toplistDataShowIn>0</toplistDataShowIn><toplistDataCaptcha>false</toplistDataCaptcha><toplistDataAddAutomatic>false</toplistDataAddAutomatic></toplist><showAverageResult>false</showAverageResult><prerequisite>false</prerequisite><showReviewQuestion>true</showReviewQuestion><quizSummaryHide>true</quizSummaryHide><skipQuestionDisabled>true</skipQuestionDisabled><emailNotification>0</emailNotification><userEmailNotification>false</userEmailNotification><showCategoryScore>false</showCategoryScore><hideResultCorrectQuestion>false</hideResultCorrectQuestion><hideResultQuizTime>false</hideResultQuizTime><hideResultPoints>false</hideResultPoints><autostart>false</autostart><forcingQuestionSolve>false</forcingQuestionSolve><hideQuestionPositionOverview>true</hideQuestionPositionOverview><hideQuestionNumbering>true</hideQuestionNumbering><sortCategories>false</sortCategories><showCategory>false</showCategory><quizModus questionsPerPage="0">2</quizModus><startOnlyRegisteredUser>true</startOnlyRegisteredUser><forms activated="false" position="0"/><questions><question answerType="single"><title>
<![CDATA[Question 1]]></title><points>1</points><questionText><![CDATA[<p>What provides guidance to the Developers on why they are building the Increment?<br />(choose the best answer)</p>]]></questionText><correctMsg><![CDATA[<p>The Sprint Goal is an objective set for the Sprint that can be met through the implementation of Product Backlog. It provides guidance to the Scrum Team on why it is building the Increment.</p>]]></correctMsg><incorrectMsg><![CDATA[<p>The Sprint Goal is an objective set for the Sprint that can be met through the implementation of Product Backlog. It provides guidance to the Scrum Team on why it is building the Increment.</p>]]></incorrectMsg><tipMsg enabled="false"><![CDATA[]]></tipMsg><category/><correctSameText>true</correctSameText><showPointsInBox>false</showPointsInBox><answerPointsActivated>false</answerPointsActivated><answerPointsDiffModusActivated>false</answerPointsDiffModusActivated><disableCorrect>false</disableCorrect><answers><answer points="1" correct="true"><answerText html="false"><![CDATA[The Sprint Goal]]></answerText><stortText html="false"><![CDATA[]]></stortText></answer><answer points="0" correct="false"><answerText html="false"><![CDATA[The Product Owner]]></answerText><stortText html="false"><![CDATA[]]></stortText></answer><answer points="0" correct="false"><answerText html="false"><![CDATA[The Scrum Master]]></answerText><stortText html="false"><![CDATA[]]></stortText></answer><answer points="0" correct="false"><answerText html="false"><![CDATA[The Sprint Backlog]]></answerText><stortText html="false"><![CDATA[]]></stortText></answer></answers></question><question answerType="single"><title>
<![CDATA[Question 2]]></title><points>1</points><questionText><![CDATA[<p>How long does a Product Backlog exists?<br />(choose the best answer)</p>]]></questionText><correctMsg><![CDATA[<p>The Product Backlog is dynamic; it constantly changes to identify what the product needs to be appropriate, competitive, and useful. If a product exists, its Product Backlog also exists.</p>]]></correctMsg><incorrectMsg><![CDATA[<p>The Product Backlog is dynamic; it constantly changes to identify what the product needs to be appropriate, competitive, and useful. If a product exists, its Product Backlog also exists.</p>]]></incorrectMsg><tipMsg enabled="false"><![CDATA[]]></tipMsg><category/><correctSameText>true</correctSameText><showPointsInBox>false</showPointsInBox><answerPointsActivated>false</answerPointsActivated><answerPointsDiffModusActivated>false</answerPointsDiffModusActivated><disableCorrect>false</disableCorrect><answers><answer points="1" correct="true"><answerText html="false"><![CDATA[As long as the Product exists.]]></answerText><stortText html="false"><![CDATA[]]></stortText></answer><answer points="0" correct="false"><answerText html="false"><![CDATA[Until the final Product Release.]]></answerText><stortText html="false"><![CDATA[]]></stortText></answer><answer points="0" correct="false"><answerText html="false"><![CDATA[Not more than 3 years.]]></answerText><stortText html="false"><![CDATA[]]></stortText></answer><answer points="0" correct="false"><answerText html="false"><![CDATA[As long as a Developer is doing work from it.]]></answerText><stortText html="false"><![CDATA[]]></stortText></answer></answers></question><question answerType="single"><title>
<![CDATA[Question 3]]></title><points>1</points><questionText><![CDATA[<p>Peter has been asked to take the Product Owner role of a large<br />product initiative. 4 teams new to Scrum will be building this product. He has created the initial Product Backlog but is unsure of how to minimize the dependencies between the Scrum Teams.<br />Which of the following would be the best advice to give Peter?<br />(choose the best answer)</p>]]></questionText><correctMsg><![CDATA[<p>Because the Developers are the ones doing the work, they would be the best ones to help the Product Owner analyze and reduce the dependencies between the work to be done.</p>]]></correctMsg><incorrectMsg><![CDATA[<p>Because the Developers are the ones doing the work, they would be the best ones to help the Product Owner analyze and reduce the dependencies between the work to be done.</p>]]></incorrectMsg><tipMsg enabled="false"><![CDATA[]]></tipMsg><category/><correctSameText>true</correctSameText><showPointsInBox>false</showPointsInBox><answerPointsActivated>false</answerPointsActivated><answerPointsDiffModusActivated>false</answerPointsDiffModusActivated><disableCorrect>false</disableCorrect><answers><answer points="1" correct="false"><answerText html="false"><![CDATA[The Product Owner creates separate Product Backlogs for each team.]]></answerText><stortText html="false"><![CDATA[]]></stortText></answer><answer points="0" correct="false"><answerText html="false"><![CDATA[The Product Owner identifies the dependent items and re-order the Product Backlog items for the Scrum Teams.]]></answerText><stortText html="false"><![CDATA[]]></stortText></answer><answer points="0" correct="true"><answerText html="false"><![CDATA[The Product Owner works with the Developers from all Scrum Teams on how to best analyze and break apart the work.]]></answerText><stortText html="false"><![CDATA[]]></stortText></answer><answer points="0" correct="false"><answerText html="false"><![CDATA[The Product Owner has the Technical Leads determine which items will be assigned to which team.]]></answerText><stortText html="false"><![CDATA[]]></stortText></answer><answer points="0" correct="false"><answerText html="false"><![CDATA[The Product Owner notifies the Scrum Master so he/she can resolve the impediment.]]></answerText><stortText html="false"><![CDATA[]]></stortText></answer></answers></question><question answerType="single"><title>
<![CDATA[Question 4]]>
and JSON file looks like that :
[
{
"question": "Who supports the Scrum Master in removing impediments?\n(choose the best three answers)\nChoose ALL answers that apply.",
"correct": [
"Management",
"The Product Owner",
"The Developers"
],
"incorrect": [
"The customer"
],
"explic": "The Developers can help the Scrum Master because of their understanding of how the work is done and their internal interactions with each other. Some impediments are rooted in external causes and that's why the Scrum Master might need to have the senior management's support in removing them. The Product Owner can also support the Scrum Master by managing stakeholder expectations."
},
{
"question": "Which TWO of the following statements are true?\n(choose the best two answers)\nChoose ALL answers that apply.",
"correct": [
"Early feedback enables agile teams to deliver features with the highest business value first, because the customer maintains focus on features with the highest system value.",
"Early feedback makes it more likely that the system built is what the customer wanted because they are given the opportunity to make changes throughout the iteration."
],
"incorrect": [
"Early feedback reduces costs because it decreases the amount of time needed for system testing.",
"Early feedback gives the Developers more time to develop new system features because they spend less time reworking features expected in a given iteration."
],
"explic": "Agile teams are highly flexible and adaptive. These strengths continue operating in single, several, many, and networks of teams that develop, release, operate and sustain the work and work products of thousands of people. They collaborate and interoperate with team members and stakeholders in order to maximize opportunities of success."
}
]
So in this case I can only import XML files, I guess I am supposed to convert this JSON file in XML, but I dont know if it s possible, and if yes do you have an idea please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当然,这是一种非常奇怪的XML格式。
我开始为您做XSLT 3.0样式表,但是我无法确定输入和输出之间的对应关系,所以我放弃了。 XSLT 3.0可以解析和处理JSON输入,并且可以生成XML输出,因此它拥有您需要的一切。
主要的技术困难是:
(a)XML格式具有包含CDATA的元素,其中包含似乎是HTML的元素。您可以在XSLT 3.0中构造它 - 使用Method =“ HTML”使用Serialize()函数来构造包含HTML的字符串,然后将其复制到XML结果树中。 (默认情况下,HTML将使用实体参考而不是CDATA逃脱,但可能是WordPress都可以接受;如果不是,您可以通过在XSL中使用CDATA截面元素强制CDATA:
XML格式(b)也是如此在不需要的情况下,可以自由地使用CDATA。输出/CDATA段元素。
It's certainly possible, but it's a pretty weird XML format.
I started doing an XSLT 3.0 stylesheet for you, but I couldn't work out the correspondence between the input and the output, so I gave up. XSLT 3.0 can parse and process JSON input, and can generate XML output, so it's got everything you need.
The main technical difficulties are:
(a) the XML format has elements containing CDATA containing what appears to be HTML. You can construct that in XSLT 3.0 - use the serialize() function with method="html" to construct a string containing HTML, and then copy this into the XML result tree. (By default the HTML will be escaped using entity references rather than CDATA, but the chances are that Wordpress will accept either; if not, you can force CDATA by using cdata-section-elements in xsl:output
(b) the XML format also makes liberal use of CDATA where it isn't needed. Chances are that this was pure laziness on the part of the people writing the export software, and it's not actually needed when importing; but again, if you do need it, use xsl:output/cdata-section-elements.