I am trying to parse an XML string with NSXMLParser that I created in PHP. My PHP sript:
$doc = new DomDocument('1.0');
$root = $doc->createElement("root");
$root = $doc->appendChild($root);
$child = $doc->createElement("child");
$child = $root->appendChild($child);
$value = $doc->createTextNode("testvar");
$value = $child->appendChild($value);
$xml_string = $doc->saveXML();
print $xml_string;
If I open the page in a browser, it will show me "testvar" as it should. Showing the source, it shows me that there are several spaces:
begin ->| <?xml version="1.0"?>
<root><child>testvar</child></root>
|<--end
Setting preserveWhitespace to false does not change anything. So I tried with regex in php:
$xml_string1 = preg_replace("/\s+</","<",$xml_string);
$xml_string2 = preg_replace("/>\s+/",">",$xml_string1);
print $xml_string2;
This removes \ n and leads me to this
begin-->| <?xml version="1.0"?><root><child>testvar</child></root> |<--end
The browser always displays the desired result: testvar
On iphone, I get the following error:
**NSXMLParserErrorDomain Code = 64, Operation could not be completed.**
I do not know what the problem is with xml, I get it correctly, as in this section. Deletes \ n ....
, [parser parse] (, ), parserError.
xml, , , .
iPhone , UTF8 ASCII.
,
stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet
.
:
[parser setShouldProcessNamespaces:NO]
[parser setShouldReportNamespacePrefixes:NO]
[parser setShouldResolveExternalEntities:NO]
, , , .
.