如何使用XML内容读取String的内容并将其另存为XML

时间:2013-07-20 22:00:32

标签: java xml string csv

我正在尝试阅读包含XML字段的String的内容: -

String developer = "<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.priceover.com/pg_2.73.xsd">
<version>2.73</version>
<api_request_id>hashkeyint</api_request_id> <priceover_url>http://www.priceover.com/</priceover_url>
<priceover_url_text>Online Deals at Priceover.com</priceover_url_text><partner_url/><market>US</market></document>";

2 个答案:

答案 0 :(得分:1)

一种方法是使用Java's DOM library。另一个是Java's SAX library

答案 1 :(得分:0)

也许我在形成时稍微打破了你的问题,但如果你的问题只是qoutes,你只需要用反斜杠来掩盖它们:

String example = "My string with \"quotes\"";

如果您的问题是解析xml的主要问题,请阅读eebbesen's answer