Unicode字符问题(Unicode character issue)
我有一个unicode字符₮在标签和UITextView中显得很好但是当我将它显示为UITableView单元格的文本时,它显示为问号。
我在这里遗漏了什么,或者不同的iOS控件支持不同的字符集? 在后端,字符来自NSString,标签只显示所选UITableView单元格的文本:
self.MyLabel.text = cell.textLabel.text;
请参阅下面的截图以供参考。
I have a unicode character ₮ which is appearing fine in a label and UITextView but when I display it as text of a UITableView cell, it appears as a question mark.
Am I missing something here, or different iOS controls support different character sets? At backend, character is coming from an NSString and label is just showing text of selected UITableView cell:
self.MyLabel.text = cell.textLabel.text;
Please see below screenshot for reference.
原文:https://stackoverflow.com/questions/16019644
最满意答案
您最好使用SimpleXML,然后您可以更直观地访问各种组件。 上面的例子就像......
$data = <<< XML <companies> <company> <vatno>12345678</vatno> <name> <founded>2013-12-31</founded> <text>XYZ Inc</text> </name> <location> <streetname>West Road</streetname> <county> <no>12345</no> <text>East County</text> </county> </location> </company> </companies> XML; $xml = simplexml_load_string($data); foreach ( $xml->company as $company ) { echo $company->vatno.PHP_EOL; echo $company->location->county->text.PHP_EOL; }
因此每个子元素都使用
->
来访问。如果你想坚持你已有的东西,你应该可以使用...
$countyName = $xmlObject->item($i)->getElementsByTagName('text')->item(1) ->nodeValue;
使用
item(1)
将获取<text>
元素的第二个实例,所以这个假设名字也会有这个值。You may be better off using SimpleXML, you can then access the various components in a more intuitive way. The example above would be something like...
$data = <<< XML <companies> <company> <vatno>12345678</vatno> <name> <founded>2013-12-31</founded> <text>XYZ Inc</text> </name> <location> <streetname>West Road</streetname> <county> <no>12345</no> <text>East County</text> </county> </location> </company> </companies> XML; $xml = simplexml_load_string($data); foreach ( $xml->company as $company ) { echo $company->vatno.PHP_EOL; echo $company->location->county->text.PHP_EOL; }
So each sub element is accessed using
->
.If you wanted to stick with what you already had, you should be able to use...
$countyName = $xmlObject->item($i)->getElementsByTagName('text')->item(1) ->nodeValue;
Using
item(1)
will fetch the second instance of the<text>
elements, so this assumes that the name will have this value as well.
相关问答
更多-
public Map
countElements(File xmlFile) { Map counts = new HashMap<>(); try { XMLInputFactory inputFactory = XMLInputFactory.newInstance(); FileInputStream fileInputStream = new FileInputStream(xml ... -
你应该把你的结果列入清单。 这就是为什么它无法计数。 此外,我建议,使您的控制cek.Count() > 0不cek.Count() == 1 。 尝试这个: var cek = (from ss in doc.Root.Descendants("Siparis") where ss.Element("pass").Value == sifre select ss).ToList(); if (cek.Cou ...
-
Node node = nodel.item(a); if(node instanceof Element) { data = ((Element)node).getAttribute("name"); System.out.println(data); } Node node = nodel.item(a); if(node instanceof Element) { data = ((Element)node).getAttribute("name"); System.out.prin ...
-
因此,如果您有两个XDocument ,那么对于每个示例XML,分别称为doc1和doc1 ,则此代码为: var ns1 = doc1.Root.GetDefaultNamespace(); var ns2 = doc2.Root.GetDefaultNamespace(); var functionCode1 = doc1.Root.Descendants(ns1 + "FunctionCode").First().Value; var functionCode2 = doc2.Root.Descen ...
-
我无法使用XQUERY获取值,而是首先,我将列'DATA'的值作为String,然后使用以下方法(使用Xpath)获取节点'Name'的值。 public String getEmpNameFromEmployee(String employeeXml) throws SAXException, IOException, XPathExpressionException { DocumentBuilderFactory builderFactory = DocumentBuilderFactor ...
-
XML获取特定元素(XML Get a specific element)[2022-09-24]
var emails = xmlContent.Root.Elements("Resources").Elements("item").Elements("emails"); foreach (XElement elem in emails) { Console.Write(elem.Value); } 这样可行。 你有拼写错误。 XML区分大小写 var emails = xmlContent.Root.Elements("Reso ... -
您可以使用这样的XPath表达式来查找相关节点: //*[@name='test2'] 然后使用Select-Xml cmdlet和foreach循环迭代匹配的节点: foreach($result in Select-Xml -Path document.xml -XPath "//*[@name='test2']"){ # Work with $result.Node in here } You can use an XPath expression like this to find th ...
-
您可以使用Xpath直接获取具有少于3个value子项的region property元素。 之后,从3减去子项计数,您将获得需要添加的值节点数。 使用简单的循环添加节点。 $root = simplexml_load_file($xml_src); $regions = $root->xpath('//property[@name = "region" and count(value) < 3]'); foreach ($regions as $region) { $difference = 3 - ...
-
您最好使用SimpleXML,然后您可以更直观地访问各种组件。 上面的例子就像...... $data = <<< XML
12345678 2013-12-31 XYZ Inc West ... -
使用php在嵌套xml中获取具有特定属性的多个值(Getting multiple values with specific attributes in nested xml with php)[2022-01-15]
您可以使用XPath获取具有特定属性值的子元素: foreach($image as $node) { $id = (string) $node->xpath('field[@name="id"]')[0]; $url = (string) $node->xpath('field[@name="image_url_big"]')[0]; echo $id . " : " . $url . "
"; } eval.in demo 输出: 55 : http://example. ...