我正在使用javax.xml
&删除一些节点后:
docBuilderFactory = DocumentBuilderFactory.newInstance();
docBuilder = docBuilderFactory.newDocumentBuilder();
document = docBuilder.parse(new File("file_name"));
NodeList tagList = document.getElementsByTagName("tag_name");
tagList.item(0).getParentNode().removeChild(waysList.item(0));
我没有删除标签,而是一条空行。
如何避免这种情况或删除空行?
XML文件是:
<root>
<tag_name>text</tag_name>
<tag_name>text</tag_name>
<tag_name>text</tag_name>
</root>
编辑:
如果我在tagList.item(0).getParentNode().setTextContent("");
之前或之后添加removeChild
,我会收到NullPointerException。
谢谢,
答案 0 :(得分:4)
在元素之前缩进,并且在它是文本节点之后返回Carriage。如果删除元素并在其之前或之后有文本节点,则会将其视为空白行。
: error: com.blabla.blabla.webapi.place.PlaceRequests cannot be provided without an @Provides-annotated method.
void inject(CityFragment cityFragment);
^
com.blabla.blabla.screens.city.CityFragment.presenter
[injected field of type: com.blabla.blabla.screens.city.CityPresenter presenter]
com.blabla.blabla.di.modules.CityModule.providePresenter(com.blabla.blabla.screens.city.CityMvp.View cityView, com.blabla.blabla.screens.city.CityMvp.Interactor interactor)
[parameter: com.blabla.blabla.screens.city.CityMvp.Interactor interactor]
com.blabla.blabla.di.modules.CityModule.provideInteractor(com.blabla.blabla.webapi.place.PlaceRequests placeRequests)
[parameter: com.blabla.blabla.webapi.place.PlaceRequests placeRequests]
3 errors
:app:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.