如何解析HTML/XML并从中提取信息?
我的意思是100多MB大; 这样的文本文件可以推动编辑的信封.
我需要查看一个大型XML文件,但如果编辑器有错误则无法查看.
有什么建议?
我经常CDATA
在XML
文件中找到这个奇怪的标签:
<![CDATA[some stuff]]>
Run Code Online (Sandbox Code Playgroud)
我观察到这个CDATA
标签总是在开头,然后是一些东西.
但有时它被使用,有时则不然.我假设它是标记some stuff
那将在之后插入的"数据".但是什么样的数据some stuff
呢?我在XML标签中写的东西不是某种数据吗?
我在包含xml的数据库中有很多行,我正在尝试编写一个Python脚本,该脚本将遍历这些行并计算特定节点属性的实例数量.例如,我的树看起来像:
<foo>
<bar>
<type foobar="1"/>
<type foobar="2"/>
</bar>
</foo>
Run Code Online (Sandbox Code Playgroud)
如何使用Python访问XML中的属性1和2?
从最新的ADT版本开始,我注意到布局XML文件上的这个新属性,例如:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".MainActivity" />
Run Code Online (Sandbox Code Playgroud)
什么是"工具:上下文"用于?
它怎么知道写在那里的活动的确切路径?它是否在清单中查看应用程序的包?
它仅限于扩展Context或仅扩展活动的类吗?它可用于ListView项目等吗?
xml android android-context android-layout android-tools-namespace
如何在XML中注释掉一个标记块?
即我如何<staticText>
在下面的代码中注释掉它里面的所有内容?
<detail>
<band height="20">
<staticText>
<reportElement x="180" y="0" width="200" height="20"/>
<text><![CDATA[Hello World!]]></text>
</staticText>
</band>
</detail>
Run Code Online (Sandbox Code Playgroud)
我可以使用,<!-- staticText-->
但这只是用于单个标签(就像我所知道的那样),就像//
在Java和C中一样.我想更像是如何/** comment **/
在Java和C中使用,所以我可以注释掉更长的XML代码块.
这是我的布局代码;
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:text="@string/welcome"
android:id="@+id/TextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</TextView>
<LinearLayout android:id="@+id/LinearLayout"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom">
<EditText android:id="@+id/EditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</EditText>
<Button android:text="@string/label_submit_button"
android:id="@+id/Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这看起来像在左边,我希望它看起来像在右边.
显而易见的答案是在高度上将TextView设置为fill_parent,但这不会为按钮或输入字段留下任何余地.本质上问题是我希望提交按钮和文本条目在底部是固定高度,文本视图填充剩余的空间,类似于水平线性布局我希望提交按钮包装其内容和用于填充剩余空间的文本条目.
如果线性布局中的第一个项目被告知fill_parent它就是这样做的,没有其他项目的空间,我如何获得一个线性布局中的第一个项目来填充除了其余项目所需的最小空间之外的所有空间布局中的项目?
编辑:
相对布局确实是答案 - 谢谢!
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:text="@string/welcome"
android:id="@+id/TextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true">
</TextView>
<RelativeLayout
android:id="@+id/InnerRelativeLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<Button
android:text="@string/label_submit_button"
android:id="@+id/Button"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
<EditText
android:id="@+id/EditText"
android:layout_width="fill_parent"
android:layout_toLeftOf="@id/Button"
android:layout_height="wrap_content">
</EditText>
</RelativeLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud) 有没有办法重新缩进代码块?我在Eclipse中寻找类似于Ctrl+ Shift+的东西F(自动格式/缩进).
要清楚,
我已经了解NppAutoIndent - 它不起作用,因为我正在使用XML,HTML和CSS.
是不是有一种方便的方法从java.util.Date到XMLGregorianCalendar?
xml ×10
android ×2
auto-indent ×1
cdata ×1
character ×1
comments ×1
date ×1
editor ×1
escaping ×1
html ×1
html-parsing ×1
java ×1
large-files ×1
notepad++ ×1
parsing ×1
php ×1
python ×1
text-editor ×1
windows ×1
xml-parsing ×1