<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3106098</guid>
        <pubDate>Wed, 28 Mar 2012 16:25:15 +0000</pubDate>
        <title>Парсинг xml</title>
        <link>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3106098</link>
        <description><![CDATA[muskos: <strong class='tag-b'>mrco</strong> Я ПРОСТО В ШОКЕ&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33; СПАСИБО БОЛЬШОЕ&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;&#33;]]></description>
        <author>muskos</author>
        <category>Android</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3106025</guid>
        <pubDate>Wed, 28 Mar 2012 15:04:18 +0000</pubDate>
        <title>Парсинг xml</title>
        <link>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3106025</link>
        <description><![CDATA[mrco: С сервера xml приходит в какой кодировке?<br>Если utf-8 то попробуйте line = EntityUtils.toString(httpEntity, &quot;UTF-8&quot;);]]></description>
        <author>mrco</author>
        <category>Android</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105980</guid>
        <pubDate>Wed, 28 Mar 2012 14:14:37 +0000</pubDate>
        <title>Парсинг xml</title>
        <link>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105980</link>
        <description><![CDATA[muskos: На всякий случай покажу, где переменная line лежит...и в какой момент она что делает...<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">public static String getXML(){ &nbsp; </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;String line = null;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;try {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DefaultHttpClient httpClient = new DefaultHttpClient();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HttpPost httpPost = new HttpPost(&quot;http://alfoot.net/newfile.xml&quot;);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HttpResponse httpResponse = httpClient.execute(httpPost);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HttpEntity httpEntity = httpResponse.getEntity();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;line = EntityUtils.toString(httpEntity);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} catch (UnsupportedEncodingException e) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;line = &quot;&#60;results status=\&quot;error\&quot;&#62;&#60;msg&#62;Can&#39;t connect to server&#60;/msg&#62;&#60;/results&#62;&quot;;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} catch (MalformedURLException e) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;line = &quot;&#60;results status=\&quot;error\&quot;&#62;&#60;msg&#62;Can&#39;t connect to server&#60;/msg&#62;&#60;/results&#62;&quot;;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} catch (IOException e) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;line = &quot;&#60;results status=\&quot;error\&quot;&#62;&#60;msg&#62;Can&#39;t connect to server&#60;/msg&#62;&#60;/results&#62;&quot;;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return line;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script><br>
<br>
Хорошо, тогда ЧТО ЖЕ ЭТО МОЖЕТ БЫТЬ((( У МЕНЯ УЖЕ ГОЛОВА КРУГОМ)))) :crazy:]]></description>
        <author>muskos</author>
        <category>Android</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105975</guid>
        <pubDate>Wed, 28 Mar 2012 14:12:01 +0000</pubDate>
        <title>Парсинг xml</title>
        <link>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105975</link>
        <description><![CDATA[Британский учёный: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=354149&view=findpost&p=3105933'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>muskos &#064; <time class="tag-quote__quoted-time" datetime="2012-03-28T13:33:42+00:00">28.03.12, 13:33</time></span><div class='quote '>Переменная line в месте где должны быть наши буковки русские...уже хранит абракадабру - </div></div><br>
Тоесть ПЕРЕД парсингом уже фигня в строке? Тогда парсер не причёмю]]></description>
        <author>Британский учёный</author>
        <category>Android</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105933</guid>
        <pubDate>Wed, 28 Mar 2012 13:33:42 +0000</pubDate>
        <title>Парсинг xml</title>
        <link>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105933</link>
        <description><![CDATA[muskos: Самое обидное...то, что уже столько получилось копипастом...и на одной фишке легло((( <br>
<br>
<span class="tag-color tag-color-named" data-value="gray" style="color: gray"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2012-03-28T13:59:09+00:00">28.03.12, 13:59</time></span></span><br>
Это переменная doc<br>
03-28 13:58:07.523: I/System.out(305): &#33;: org.apache.harmony.xml.dom.DocumentImpl@44f69f88<br>
Переменная line в месте где должны быть наши буковки русские...уже хранит абракадабру - <br>
03-28 13:59:44.493: I/System.out(333): 		&lt;name&gt;&#208;&#154;&#208;&#190;&#208;&#188;&#208;°&#208;&#189;&#208;&#180;&#208;° &#208;&#144; - &#208;&#154;&#208;&#190;&#208;&#188;&#208;°&#208;&#189;&#208;&#180;&#208;° &#208;&#145;&lt;/name&gt;<br>
<br>
<strong class='tag-b'>mrco</strong>, вы имели в виду этот вход? Или есть ещё где?]]></description>
        <author>muskos</author>
        <category>Android</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105707</guid>
        <pubDate>Wed, 28 Mar 2012 11:10:39 +0000</pubDate>
        <title>Парсинг xml</title>
        <link>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105707</link>
        <description><![CDATA[muskos: <strong class='tag-b'>Британский учёный</strong><br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">public class XMLParser {</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;public final static Document XMLfromString(String xml){</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Document doc = null;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;//DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;//DocumentBuilder builder = dbf.newDocumentBuilder();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;try {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DocumentBuilder builder = dbf.newDocumentBuilder();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DocumentBuilder db = dbf.newDocumentBuilder();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//StringReader sr = new StringReader(xml); </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//InputSource is = new InputSource(sr);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//is.setCharacterStream(new StringReader(xml));</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//is.setEncoding(&quot;utf-8&quot;);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ByteArrayInputStream encXML = new ByteArrayInputStream(xml.getBytes(&quot;UTF8&quot;));</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;doc = builder.parse(encXML); </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;} catch (ParserConfigurationException e) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(&quot;XML parse error: &quot; + e.getMessage());</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return null;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;} catch (SAXException e) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(&quot;Wrong XML file structure: &quot; + e.getMessage());</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return null;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;} catch (IOException e) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(&quot;I/O exeption: &quot; + e.getMessage());</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return null;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return doc;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div></ol></div></div></div></div><br>
<br>
методом тыка испробовал много вариантов...всё равно кодировку не меняет( <br>
<br>
<span class="tag-color tag-color-named" data-value="gray" style="color: gray"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2012-03-28T11:11:58+00:00">28.03.12, 11:11</time></span></span><br>
<strong class='tag-b'>mrco</strong> знаний не хватает - проверить что в строке на входе((( <br>
<br>
<span class="tag-color tag-color-named" data-value="gray" style="color: gray"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2012-03-28T11:45:17+00:00">28.03.12, 11:45</time></span></span><br>
<strong class='tag-b'>mrco</strong> Я слегка не понимаю про Response... У меня всё тоже самое, кроме одной строчки, только раскидано между функциями...<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">public class XMLParser {</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;public final static Document XMLfromString(String xml){</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Document doc = null;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;dbf.setNamespaceAware(true); // never forget this!</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;try {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DocumentBuilder db = dbf.newDocumentBuilder();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;InputSource is = new InputSource();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;is.setCharacterStream(new StringReader(xml));</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;doc = db.parse(is); </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;} catch (ParserConfigurationException e) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(&quot;XML parse error: &quot; + e.getMessage());</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return null;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;} catch (SAXException e) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(&quot;Wrong XML file structure: &quot; + e.getMessage());</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return null;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;} catch (IOException e) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(&quot;I/O exeption: &quot; + e.getMessage());</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return null;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return doc;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;/** Returns element value</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;* @param elem element (it is XML tag)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;* @return Element value otherwise empty String</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;*/</div><div class="code_line">&nbsp;&nbsp; &nbsp; public final static String getElementValue( Node elem ) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; Node kid;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; if( elem != null){</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (elem.hasChildNodes()){</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for( kid = elem.getFirstChild(); kid != null; kid = kid.getNextSibling() ){</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if( kid.getNodeType() == Node.TEXT_NODE &nbsp;){</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return kid.getNodeValue();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; }</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; return &quot;&quot;;</div><div class="code_line">&nbsp;&nbsp; &nbsp; }</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; </div><div class="code_line">&nbsp;&nbsp; &nbsp; public static String getXML(){ &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;String line = null;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;try {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DefaultHttpClient httpClient = new DefaultHttpClient();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HttpPost httpPost = new HttpPost(&quot;http://alfoot.net/newfile.xml&quot;);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HttpResponse httpResponse = httpClient.execute(httpPost);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;InputStream in = httpResponse.getEntity().getContent();//</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HttpEntity httpEntity = httpResponse.getEntity();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;line = EntityUtils.toString(httpEntity);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} catch (UnsupportedEncodingException e) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;line = &quot;&#60;results status=\&quot;error\&quot;&#62;&#60;msg&#62;Can&#39;t connect to server&#60;/msg&#62;&#60;/results&#62;&quot;;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} catch (MalformedURLException e) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;line = &quot;&#60;results status=\&quot;error\&quot;&#62;&#60;msg&#62;Can&#39;t connect to server&#60;/msg&#62;&#60;/results&#62;&quot;;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} catch (IOException e) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;line = &quot;&#60;results status=\&quot;error\&quot;&#62;&#60;msg&#62;Can&#39;t connect to server&#60;/msg&#62;&#60;/results&#62;&quot;;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return line;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;// final HttpResponse response = mHttpClient.execute(request);</div><div class="code_line">&nbsp;&nbsp; &nbsp; // &nbsp; final InputStream in = response.getEntity().getContent();</div><div class="code_line">&nbsp;&nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;public static int numResults(Document doc){ &nbsp; &nbsp; </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Node results = doc.getDocumentElement();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;int res = -1;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;try{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;res = Integer.valueOf(results.getAttributes().getNamedItem(&quot;count&quot;).getNodeValue());</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}catch(Exception e ){</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;res = -1;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return res;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;public static String getValue(Element item, String str) { &nbsp; &nbsp; &nbsp; </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;NodeList n = item.getElementsByTagName(str); &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return XMLParser.getElementValue(n.item(0));</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">}</div></ol></div></div></div></div>]]></description>
        <author>muskos</author>
        <category>Android</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105691</guid>
        <pubDate>Wed, 28 Mar 2012 10:56:36 +0000</pubDate>
        <title>Парсинг xml</title>
        <link>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105691</link>
        <description><![CDATA[mrco: В общем-то:<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">InputSource is = new InputSource();</div><div class="code_line">is.setCharacterStream(new StringReader(xml));</div><div class="code_line">doc = db.parse(is);</div></ol></div></div></div></div><br>
должно работать. без каких либо указаний кодировок, потому что на входе у вас String. А он бывает только в одной кодировке.<br>
1. Проверьте что у вас в строке на входе в метод XMLfromString, если она битая, то дальше ничего уже не исправить.<br>
2. У вас Response от сервера сначала перегоняеться в строку, а потом из строки в xml документ. Это лишние действия:<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;final HttpResponse response = mHttpClient.execute(request);</div><div class="code_line">&nbsp;&nbsp; &nbsp;final InputStream in = response.getEntity().getContent();</div><div class="code_line">&nbsp;&nbsp; &nbsp;DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();</div><div class="code_line">&nbsp;&nbsp; &nbsp;factory.setNamespaceAware(true); // never forget this!</div><div class="code_line">&nbsp;&nbsp; &nbsp;DocumentBuilder builder = factory.newDocumentBuilder();</div><div class="code_line">&nbsp;&nbsp; &nbsp;Document doc = builder.parse(in);</div></ol></div></div></div></div><br>
этот фрагмент гарантированно работает с UTf-8.]]></description>
        <author>mrco</author>
        <category>Android</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105689</guid>
        <pubDate>Wed, 28 Mar 2012 10:56:29 +0000</pubDate>
        <title>Парсинг xml</title>
        <link>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105689</link>
        <description><![CDATA[muskos: хух)) расслабил)<br>на стековерфло всё пытаются на шрифт давить и кодировку....думаю проблема не в этом..]]></description>
        <author>muskos</author>
        <category>Android</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105678</guid>
        <pubDate>Wed, 28 Mar 2012 10:43:17 +0000</pubDate>
        <title>Парсинг xml</title>
        <link>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105678</link>
        <description><![CDATA[mrco: Не, я ошибся. Это сосвем не то что нужно.]]></description>
        <author>mrco</author>
        <category>Android</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105607</guid>
        <pubDate>Wed, 28 Mar 2012 09:25:11 +0000</pubDate>
        <title>Парсинг xml</title>
        <link>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105607</link>
        <description><![CDATA[muskos: <strong class='tag-b'>mrco</strong> Эм...я ноль))) Ну, спасибо, почитаю, может просветит)]]></description>
        <author>muskos</author>
        <category>Android</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105605</guid>
        <pubDate>Wed, 28 Mar 2012 09:12:32 +0000</pubDate>
        <title>Парсинг xml</title>
        <link>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105605</link>
        <description><![CDATA[mrco: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=354149&view=findpost&p=3105445'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>muskos &#064; <time class="tag-quote__quoted-time" datetime="2012-03-28T06:47:33+00:00">28.03.12, 06:47</time></span><div class='quote '>public class XMLParser {<br>
 <br>
    public final static Document XMLfromString(String xml){<br>
 <br>
        Document doc = null;<br>
 <br>
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();<br>
        try {<br>
 <br>
            DocumentBuilder db = dbf.newDocumentBuilder();<br>
 <br>
            InputSource is = new InputSource();<br>
            is.setCharacterStream(new StringReader(xml));<br>
            doc = db.parse(is);<br>
 <br>
        } catch (ParserConfigurationException e) {<br>
            System.out.println(&quot;XML parse error: &quot; + e.getMessage());<br>
            return null;<br>
        } catch (SAXException e) {<br>
            System.out.println(&quot;Wrong XML file structure: &quot; + e.getMessage());<br>
            return null;<br>
        } catch (IOException e) {<br>
            System.out.println(&quot;I/O exeption: &quot; + e.getMessage());<br>
            return null;<br>
        }<br>
 <br>
        return doc;<br>
 <br>
    }</div></div><br>
Вот это не надо делать, достаточно воспользоваться методом <a class='tag-url' href='http://docs.oracle.com/javase/1.5.0/docs/api/javax/xml/parsers/DocumentBuilder.html#parse%28java.lang.String%29' target='_blank'>public Document parse(String uri)</a>]]></description>
        <author>mrco</author>
        <category>Android</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105470</guid>
        <pubDate>Wed, 28 Mar 2012 07:06:48 +0000</pubDate>
        <title>Парсинг xml</title>
        <link>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105470</link>
        <description><![CDATA[Британский учёный: <strong class='tag-b'>muskos</strong>, тести бо я у компа буду часа через 2]]></description>
        <author>Британский учёный</author>
        <category>Android</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105445</guid>
        <pubDate>Wed, 28 Mar 2012 06:47:33 +0000</pubDate>
        <title>Парсинг xml</title>
        <link>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105445</link>
        <description><![CDATA[muskos: <strong class='tag-b'>Британский учёный</strong> Вообщем...мне кажется проблема не на входе, а на выходе...<br>
Когда я смотрю в вики сравнение на кракозябры почему-то кодировку xml он принимает как надо - utf-8(или когда я менял - windows-1251)...но на выходе получается кракозябры как будто идёт перекодировка в windows-1252...<br>
Проверяю не только в эмуляторе, но и в телефоне.<br>
Версия android - 2.2. <br>
<br>
Сегодня попробовал скопипастить другой пример парсинга. Опять же английский парсит, на русский выводит перекодировку в windows-1252 <br>
<br>
<span class="tag-color tag-color-named" data-value="gray" style="color: gray"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2012-03-28T06:54:00+00:00">28.03.12, 06:54</time></span></span><br>
<strong class='tag-b'>Британский учёный</strong> Понимаете, в чём дело) Я не особо крут в ява))) принцип понимаю, но что куда - не особо) У меня слегка другой код)))<br>
Ща... <br>
<br>
<span class="tag-color tag-color-named" data-value="gray" style="color: gray"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2012-03-28T06:56:00+00:00">28.03.12, 06:56</time></span></span><br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">import javax.xml.parsers.ParserConfigurationException;</div><div class="code_line">&nbsp;</div><div class="code_line">import org.apache.http.HttpEntity;</div><div class="code_line">import org.apache.http.HttpResponse;</div><div class="code_line">import org.apache.http.client.methods.HttpPost;</div><div class="code_line">import org.apache.http.impl.client.DefaultHttpClient;</div><div class="code_line">import org.apache.http.util.EntityUtils;</div><div class="code_line">import org.w3c.dom.Document;</div><div class="code_line">import org.w3c.dom.Element;</div><div class="code_line">import org.w3c.dom.Node;</div><div class="code_line">import org.w3c.dom.NodeList;</div><div class="code_line">import org.xml.sax.InputSource;</div><div class="code_line">import org.xml.sax.SAXException;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;</div><div class="code_line">public class XMLParser {</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;public final static Document XMLfromString(String xml){</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Document doc = null;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;try {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DocumentBuilder db = dbf.newDocumentBuilder();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;InputSource is = new InputSource();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;is.setCharacterStream(new StringReader(xml));</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;doc = db.parse(is); </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;} catch (ParserConfigurationException e) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(&quot;XML parse error: &quot; + e.getMessage());</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return null;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;} catch (SAXException e) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(&quot;Wrong XML file structure: &quot; + e.getMessage());</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return null;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;} catch (IOException e) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(&quot;I/O exeption: &quot; + e.getMessage());</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return null;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return doc;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;/** Returns element value</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;* @param elem element (it is XML tag)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;* @return Element value otherwise empty String</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;*/</div><div class="code_line">&nbsp;&nbsp; &nbsp; public final static String getElementValue( Node elem ) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; Node kid;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; if( elem != null){</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (elem.hasChildNodes()){</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for( kid = elem.getFirstChild(); kid != null; kid = kid.getNextSibling() ){</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if( kid.getNodeType() == Node.TEXT_NODE &nbsp;){</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return kid.getNodeValue();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; }</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; return &quot;&quot;;</div><div class="code_line">&nbsp;&nbsp; &nbsp; }</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; </div><div class="code_line">&nbsp;&nbsp; &nbsp; public static String getXML(){ &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;String line = null;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;try {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DefaultHttpClient httpClient = new DefaultHttpClient();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HttpPost httpPost = new HttpPost(&quot;http://alfoot.net/newfile.xml&quot;);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HttpResponse httpResponse = httpClient.execute(httpPost);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HttpEntity httpEntity = httpResponse.getEntity();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;line = EntityUtils.toString(httpEntity);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} catch (UnsupportedEncodingException e) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;line = &quot;&#60;results status=\&quot;error\&quot;&#62;&#60;msg&#62;Can&#39;t connect to server&#60;/msg&#62;&#60;/results&#62;&quot;;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} catch (MalformedURLException e) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;line = &quot;&#60;results status=\&quot;error\&quot;&#62;&#60;msg&#62;Can&#39;t connect to server&#60;/msg&#62;&#60;/results&#62;&quot;;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} catch (IOException e) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;line = &quot;&#60;results status=\&quot;error\&quot;&#62;&#60;msg&#62;Can&#39;t connect to server&#60;/msg&#62;&#60;/results&#62;&quot;;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return line;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; </div><div class="code_line">&nbsp;&nbsp; &nbsp;public static int numResults(Document doc){ &nbsp; &nbsp; </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Node results = doc.getDocumentElement();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;int res = -1;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;try{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;res = Integer.valueOf(results.getAttributes().getNamedItem(&quot;count&quot;).getNodeValue());</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}catch(Exception e ){</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;res = -1;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return res;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;public static String getValue(Element item, String str) { &nbsp; &nbsp; &nbsp; </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;NodeList n = item.getElementsByTagName(str); &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return XMLParser.getElementValue(n.item(0));</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">}</div></ol></div></div></div></div><br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">package blr.first;</div><div class="code_line">&nbsp;</div><div class="code_line">import java.util.ArrayList;</div><div class="code_line">import java.util.HashMap;</div><div class="code_line">&nbsp;</div><div class="code_line">import org.w3c.dom.Document;</div><div class="code_line">import org.w3c.dom.Element;</div><div class="code_line">import org.w3c.dom.NodeList;</div><div class="code_line">&nbsp;</div><div class="code_line">import android.app.ListActivity;</div><div class="code_line">import android.os.Bundle;</div><div class="code_line">import android.view.View;</div><div class="code_line">import android.widget.AdapterView;</div><div class="code_line">import android.widget.AdapterView.OnItemClickListener;</div><div class="code_line">import android.widget.ListAdapter;</div><div class="code_line">import android.widget.ListView;</div><div class="code_line">import android.widget.SimpleAdapter;</div><div class="code_line">import android.widget.Toast;</div><div class="code_line">&nbsp;</div><div class="code_line">public class PrimierMatchActivity extends ListActivity {</div><div class="code_line">&nbsp;&nbsp; &nbsp;/** Called when the activity is first created. */</div><div class="code_line">&nbsp;&nbsp; &nbsp;@Override</div><div class="code_line">&nbsp;&nbsp; &nbsp;public void onCreate(Bundle savedInstanceState) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;super.onCreate(savedInstanceState);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;setContentView(R.layout.listplaceholder);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;ArrayList&#60;HashMap&#60;String, String&#62;&#62; mylist = new ArrayList&#60;HashMap&#60;String, String&#62;&#62;();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;String xml = XMLParser.getXML();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Document doc = XMLParser.XMLfromString(xml);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;int numResults = XMLParser.numResults(doc);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if((numResults &#60;= 0)){</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Toast.makeText(PrimierMatchActivity.this, &quot;Geen resultaten gevonden&quot;, Toast.LENGTH_LONG).show(); &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;finish();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;NodeList nodes = doc.getElementsByTagName(&quot;result&quot;);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;for (int i = 0; i &#60; nodes.getLength(); i++) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HashMap&#60;String, String&#62; map = new HashMap&#60;String, String&#62;(); &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Element e = (Element)nodes.item(i);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;map.put(&quot;id&quot;, XMLParser.getValue(e, &quot;id&quot;));</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;map.put(&quot;name&quot;, &quot;Naam:&quot; + XMLParser.getValue(e, &quot;name&quot;));</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;map.put(&quot;Score&quot;, &quot;Score: &quot; + XMLParser.getValue(e, &quot;score&quot;));</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mylist.add(map); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;} &nbsp; &nbsp; &nbsp; </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.primiermatch, </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;new String[] { &quot;name&quot;, &quot;Score&quot; }, </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;new int[] { R.id.item_title, R.id.item_subtitle });</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;setListAdapter(adapter);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;final ListView lv = getListView();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;lv.setTextFilterEnabled(true); &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;lv.setOnItemClickListener(new OnItemClickListener() {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;public void onItemClick(AdapterView&#60;?&#62; parent, View view, int position, long id) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;@SuppressWarnings(&quot;unchecked&quot;)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HashMap&#60;String, String&#62; o = (HashMap&#60;String, String&#62;) lv.getItemAtPosition(position); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Toast.makeText(PrimierMatchActivity.this, &quot;ID &#39;&quot; + o.get(&quot;id&quot;) + &quot;&#39; was clicked.&quot;, Toast.LENGTH_LONG).show(); </div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;});</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">}</div></ol></div></div></div></div><br>
<br>
вот два моих файлика...если можно, покажите куда копипастить)) <br>
<br>
<span class="tag-color tag-color-named" data-value="gray" style="color: gray"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2012-03-28T07:01:04+00:00">28.03.12, 07:01</time></span></span><br>
Кажется нашёл, но всё же, пока тестю, если сможите - отпишите) может не то нашёл)]]></description>
        <author>muskos</author>
        <category>Android</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105442</guid>
        <pubDate>Wed, 28 Mar 2012 06:44:11 +0000</pubDate>
        <title>Парсинг xml</title>
        <link>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105442</link>
        <description><![CDATA[Британский учёный: <a class='tag-url' href='http://stackoverflow.com/questions/6021719/problem-with-parsing-of-utf-8-encoded-xml-files-in-android-3-1-sdk' target='_blank'>А так не взлетит?</a>]]></description>
        <author>Британский учёный</author>
        <category>Android</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105424</guid>
        <pubDate>Wed, 28 Mar 2012 06:24:51 +0000</pubDate>
        <title>Парсинг xml</title>
        <link>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105424</link>
        <description><![CDATA[muskos: <strong class='tag-b'>Британский учёный</strong> стековерфло молчит, Хэшкод молчит...]]></description>
        <author>muskos</author>
        <category>Android</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105314</guid>
        <pubDate>Tue, 27 Mar 2012 19:45:21 +0000</pubDate>
        <title>Парсинг xml</title>
        <link>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105314</link>
        <description><![CDATA[muskos: ну, языка не хватает)<br>спросил на hashcode - молчат(((]]></description>
        <author>muskos</author>
        <category>Android</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105303</guid>
        <pubDate>Tue, 27 Mar 2012 19:25:08 +0000</pubDate>
        <title>Парсинг xml</title>
        <link>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105303</link>
        <description><![CDATA[Британский учёный: Так спроси на стековерфло, там мигом ответят.]]></description>
        <author>Британский учёный</author>
        <category>Android</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105301</guid>
        <pubDate>Tue, 27 Mar 2012 19:22:48 +0000</pubDate>
        <title>Парсинг xml</title>
        <link>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105301</link>
        <description><![CDATA[muskos: <strong class='tag-b'>Британский учёный</strong>Завтра я с ума сойду с этой кодировкой....]]></description>
        <author>muskos</author>
        <category>Android</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105291</guid>
        <pubDate>Tue, 27 Mar 2012 19:09:56 +0000</pubDate>
        <title>Парсинг xml</title>
        <link>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105291</link>
        <description><![CDATA[Британский учёный: <strong class='tag-b'>muskos</strong>, сейчас нет компа по рукой, завтра гляну.]]></description>
        <author>Британский учёный</author>
        <category>Android</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105289</guid>
        <pubDate>Tue, 27 Mar 2012 19:08:50 +0000</pubDate>
        <title>Парсинг xml</title>
        <link>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105289</link>
        <description><![CDATA[muskos: конечно(<br><br>Такое ощущение, что на выходе в win1252 каким-то образом перекодирует...(но это только ощущения)]]></description>
        <author>muskos</author>
        <category>Android</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105283</guid>
        <pubDate>Tue, 27 Mar 2012 19:07:02 +0000</pubDate>
        <title>Парсинг xml</title>
        <link>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105283</link>
        <description><![CDATA[Британский учёный: А в эксемельке в первой строке есть encoding=&quot;UTF-8&quot; ?]]></description>
        <author>Британский учёный</author>
        <category>Android</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105258</guid>
        <pubDate>Tue, 27 Mar 2012 18:39:02 +0000</pubDate>
        <title>Парсинг xml</title>
        <link>https://forum.sources.ru/index.php?showtopic=354149&amp;view=findpost&amp;p=3105258</link>
        <description><![CDATA[muskos: Есть xml. Его парсю через андройд апликэйшн. Всё получается, если английский язык. Но если поменять в xml - на русский язык, то при отображении страницы в android api - символы отображаются некорректно. Испробовал поменять кодировку в xml с utf-8 на windows-1251. Не помогло. Пробовал заставить апликацию понимать кодировку -<br>
<br>
InputSource is = new InputSource();<br>
is.setCharacterStream(new StringReader(xml));<br>
is.setEncoding (&quot;windows-1251&quot;);    <br>
doc = db.parse(is);<br>
<br>
Ничего не выходит. Может, кто сможет подсказать. Если надо больше исходника - выложу...<br>
<br>
is.setEncoding(&quot;UTF_8&quot;);<br>
<br>
тоже ничего не выходит<br>
<br>
Посмотрел в вики <a class='tag-url' href='http://ru.wikipedia.org/wiki/%D0%9A%D1%80%D0%B0%D0%BA%D0%BE%D0%B7%D1%8F%D0%B1%D1%80%D1%8B' target='_blank'>http://ru.wikipedia.org/wiki/%D0%9A%D1%80%...%B1%D1%80%D1%8B</a> Сравнил крокозябры. Если мы ставим в xml, который парсим, кодировку 1251, то крокозябры как будто идёт перекодировка из 1251 в 1252. Если мы ставим в xml кодировку utf-8, то крокозябры выглядят, как будто перекодируем из utf в 1252. В чём может быть проблема?]]></description>
        <author>muskos</author>
        <category>Android</category>
      </item>
	
      </channel>
      </rss>
	