Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/359.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/187.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
domxml解析JAVA:从ChildNodes获取嵌入标记_Java_Android_Xml Parsing_Domparser - Fatal编程技术网

domxml解析JAVA:从ChildNodes获取嵌入标记

domxml解析JAVA:从ChildNodes获取嵌入标记,java,android,xml-parsing,domparser,Java,Android,Xml Parsing,Domparser,我想得到 Für Mietwohnungen gilt bereits:Wer den Makler 贝斯特尔特,我是贝沙伦。正义部长Heiko Maas würde dieses 普林齐普·格恩 这是我的家,也是我的家 http://www.faz.net/aktuell/wirtschaft/immobilien/justizminister-maas-auch-hausverkaeufer-sollen-makler-bezahlen-14700828.html 2017年1月19日星期四

我想得到

Für Mietwohnungen gilt bereits:Wer den Makler
贝斯特尔特,我是贝沙伦。正义部长Heiko Maas würde dieses
普林齐普·格恩
这是我的家,也是我的家

http://www.faz.net/aktuell/wirtschaft/immobilien/justizminister-maas-auch-hausverkaeufer-sollen-makler-bezahlen-14700828.html 2017年1月19日星期四21:48:49+0100 http://www.faz.net/-gz7-8r38c
我正在卡片视图中显示信息:

<item>
  <title>Justizminister Maas: Auch Hausverkäufer sollen Makler bezahlen</title>
  <description>
      <img width=190 height=107 border=0 title="Heiko Maas auf dem Weg zur  
       wöchentlichen Kabinettssitzung im Kanzleramt." alt="Heiko Maas auf dem 
       Weg zur wöchentlichen Kabinettssitzung im Kanzleramt." 
       src=http://media0.faz.net/ppmedia/aktuell/653672970/1.4700918/article_teaser/heiko
       -maas-auf-dem-weg-zur.jpg />
     <p>Für Mietwohnungen gilt bereits: Wer den Makler 
        bestellt, muss ihn bezahlen. Justizminister Heiko Maas würde dieses 
        Prinzip gerne 
        auch beim Haus- und Wohnungskauf einführen.</p>
   </description>
   <link>http://www.faz.net/aktuell/wirtschaft/immobilien/justizminister-maas-auch-hausverkaeufer-sollen-makler-bezahlen-14700828.html</link>
   <pubDate>Thu, 19 Jan 2017 21:48:49 +0100</pubDate>
   <guid isPermaLink="true">http://www.faz.net/-gz7-8r38c</guid>
</item>

`
我使用的基于流程的XML方法:

<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="4dp"
app:cardBackgroundColor="@color/cardview_dark_background">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <TextView
        android:text="Date"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/pubDate"
        android:layout_below="@+id/desc"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:padding="10dp" />

    <TextView
        android:text="Beschreibung"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/desc"
        android:textColor="@color/colorAccent"
        android:padding="10dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/title" />

    <TextView
        android:text="GUID"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/pubDate"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:id="@+id/guid"
        android:padding="10dp" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:srcCompat="@mipmap/ic_launcher"
        android:id="@+id/thumbnail"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true" />

    <TextView
        android:text="Title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/title"
        android:textAppearance="@style/TextAppearance.AppCompat.Title"
        android:textAlignment="center"
        android:textColor="@color/colorAccent"
        android:background="@color/colorPrimaryDark"
        android:lines="3"
        android:padding="5dp"
        android:alpha="0.8"
        android:layout_below="@+id/thumbnail"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

</RelativeLayout>

</android.support.v7.widget.CardView>`
private void processXML(文档数据源){
if(数据源!=null){
feedItems=新的ArrayList();
Element root=dataSource.getDocumentElement();
节点通道=root.getChildNodes()。项(1);
NodeList items=channel.getChildNodes();
对于(int i=0;i
 private void processXML(Document dataSource) {
    if(dataSource!=null){
        feedItems = new ArrayList<>();
        Element root= dataSource.getDocumentElement();
        Node channel= root.getChildNodes().item(1);
        NodeList items = channel.getChildNodes();
        for(int i =0; i<items.getLength();i++){
            Node currentChild = items.item(i);
            if(currentChild.getNodeName().equalsIgnoreCase("item")){
                FeedItem item = new FeedItem();
                NodeList itemchilds = currentChild.getChildNodes();
                for (int j=0; j < itemchilds.getLength(); j++){
                    Node current = itemchilds.item(j);
                    if(current.getNodeName().equalsIgnoreCase("title")){
                        item.setTitle(current.getTextContent());
                    }else if(current.getNodeName().equalsIgnoreCase("description")){
                        item.setDescription(current.getTextContent());
                    }else if(current.getNodeName().equalsIgnoreCase("pubDate")){
                        item.setPubDate(current.getTextContent());
                    }else if(current.getNodeName().equalsIgnoreCase("guid")){
                        item.setGuid(current.getTextContent());
                    }

                    /*else if(current.getNodeName().equalsIgnoreCase("media:thumbnail")){
                        String url = current.getAttributes().item(0).getTextContent();
                        item.setThumbnailURL(url);
                    }*/
                }// end for-loop with j as variable
                feedItems.add(item);
            } // end if-loop item
        }// end for-loop with i as variable
    } // end if datasource
} // processXML