Tag: xml

在PHP中parsing巨大的XML文件

我试图将DMOZ内容/结构XML文件parsing到MySQL中,但是所有现有的脚本都是非常旧的,并且不能很好地工作。 我怎样才能在PHP中打开一个大的(+ 1GB)XML文件进行parsing?

在PreferenceActivity中使用什么而不是“addPreferencesFromResource”?

我只注意到在Android的文档( 参考条目 )中标记为弃用 addPreferencesFromResource(int preferencesResId)方法的事实。 不幸的是,在该方法的描述中没有提供替代方法。 应该使用哪种方法来将preferenceScreen.xml连接到匹配的PreferenceActivity?

在android视图中出现频繁的问题,parsingXML时出错:未绑定的前缀

我在Android视图中经常遇到问题,在Error parsing XML: unbound prefix on Line 2 。 <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:orientation="vertical" android:id="@+id/myScrollLayout" android:layout_width="fill_parent" android:layout_height="wrap_content"> <TextView android:layout_height="wrap_content" android:layout_width="fill_parent" android:text="Family" android:id="@+id/Family" android:textSize="16px" android:padding="5px" android:textStyle="bold" android:gravity="center_horizontal"> </TextView> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:scrollbars="vertical"> <LinearLayout android:orientation="vertical" android:id="@+id/myMainLayout" android:layout_width="fill_parent" android:layout_height="wrap_content"> </LinearLayout> </ScrollView> </LinearLayout>

Android:无形之间的区别和走了吗?

查看可见性状态, invisible又gone了什么?

在Java中,如何将XMLparsing为string而不是文件?

我有以下代码: DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(xmlFile); 我怎样才能parsing包含在一个string,而不是一个文件的XML?

如何在屏幕底部alignment视图?

这是我的布局代码; <?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> 这看起来像是在左边,我想要它看起来像在右边。 显而易见的答案是将TextView设置为fill_parent的高度,但这不会使button或input字段留下空间。 基本上问题是,我希望提交button和文本条目是固定的高度在底部和文本视图来填充空间的其余部分,类似的水平线性布局我希望提交button来包装其内容和为文本条目填充其余的空间。 如果线性布局中的第一个项目被告知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"> […]

内存泄漏使用StreamReader和XmlSerializer

我一直在谷歌search过去的几个小时,尝试不同的东西,但似乎无法在这个底部…. 当我运行这个代码时,内存使用量不断增长。 while (true) { try { foreach (string sym in stringlist) { StreamReader r = new StreamReader(@"C:\Program Files\" + sym + ".xml"); XmlSerializer xml = new XmlSerializer(typeof(XMLObj), new XmlRootAttribute("rootNode")); XMLObj obj = (XMLObj)xml.Deserialize(r); obj.Dispose(); r.Dispose(); r.Close(); } } catch(Exception ex) { Console.WriteLine(ex.ToString()); } Thread.Sleep(1000); Console.Clear(); } XMLObj是一个自定义对象 [Serializable()] public class XMLObj: IDisposable { [XmlElement("block")] […]

无论上下文如何,都将SimpleXML对象强制转换为string

比方说,我有这样的XML <channel> <item> <title>This is title 1</title> </item> </channel> 下面的代码做我想要的,它输出标题作为一个string $xml = simplexml_load_string($xmlstring); echo $xml->channel->item->title; 这是我的问题。 下面的代码不会将该标题看作是该上下文中的string,所以我最终将在数组中使用SimpleXML对象而不是string。 $foo = array( $xml->channel->item->title ); 我一直在这样做 $foo = array( sprintf("%s",$xml->channel->item->title) ); 但这似乎是丑陋的。 无论上下文如何,将SimpleXML对象强制为string的最佳方式是什么?

Xml序列化 – 隐藏空值

当使用标准的.NET Xml Serializer时,有没有什么办法可以隐藏所有的空值? 以下是我class的输出示例。 如果它们设置为null,我不想输出可为空的整数。 当前的Xml输出: <?xml version="1.0" encoding="utf-8"?> <myClass> <myNullableInt p2:nil="true" xmlns:p2="http://www.w3.org/2001/XMLSchema-instance" /> <myOtherInt>-1</myOtherInt> </myClass> 我想要的是: <?xml version="1.0" encoding="utf-8"?> <myClass> <myOtherInt>-1</myOtherInt> </myClass>

如何parsingXML到R数据框

我试图parsingXML到R数据框,这个链接帮了我很多: 如何从xml文件创build一个R数据框 但是我还是无法弄清我的问题: 这是我的代码: data <- xmlParse("http://forecast.weather.gov/MapClick.php?lat=29.803&lon=-82.411&FcstType=digitalDWML") xmlToDataFrame(nodes=getNodeSet(data1,"//data"))[c("location","time-layout")] step1 <- xmlToDataFrame(nodes=getNodeSet(data1,"//location/point"))[c("latitude","longitude")] step2 <- xmlToDataFrame(nodes=getNodeSet(data1,"//time-layout/start-valid-time")) step3 <- xmlToDataFrame(nodes=getNodeSet(data1,"//parameters/temperature"))[c("type="hourly"")] 我想要的数据框是这样的: latitude longitude start-valid-time hourly_temperature 29.803 -82.411 2013-06-19T15:00:00-04:00 91 29.803 -82.411 2013-06-19T16:00:00-04:00 90 我卡在xmlToDataFrame,任何帮助将非常感激,谢谢。