Friday 15 July 2011

iphone - GDataXMLDocument nodesForXPath return an error -


I need your help, I want to parse an XML file using the GDataXMLDocument I have to fetch and fetch special tags all the attributes but when I am using or just provide the value of XPath to get me the columnHeading value

  GDataXMLDocument * doc = [[GDataXMLDocument alloc] initWithData : [NSData dataWithContentsOfFile: Path] Encoding: NSUTF8StringEncoding Error: Zero]; NSArray * tempArray = [Doctor nodes forexpath: @ "// root / xsd: schema" namespace: zero error: zero];   

This error returns below

XPath error: Undefined Namespace prefix xmlXPathEval: Evaluation failed

And here's my XML content < / P>

  & lt; XML version = "1.0". Encoding = "utf-8" & gt; & Lt; SH xmlns = "karash: schema-microsoft-com: xml-analysis: resize" & gt; & Lt; XSD: schema xmlns: XSD = "http://www.w3.org/2001/XMLSchema" xmlns: seen SQL = "vase: seen SQL" targetNamespace = "vase: schema-microsoft com: xml-analysis: rowset" & Gt; & Lt; Xsd: complex type name = "r" & gt; & Lt; XSD: Sequence & gt; & Lt; Xsd: element name = "s 0" seen-sql: columnHeading = "SID" seen-sql: columnID = "0" /> & Lt; Xsd: element name = "S1" seen-sql: columnHeading = "SNAME" seen-sql: columnID = "1" /> & Lt; Xsd: element name = "s2" seen-sql: column heading = "class" seen-sql: columnID = "2" /> & Lt; Xsd: element name = "S3" seen-SQL: column header = "ADD" seen-SQL: columnID = "3" /> & Lt; Xsd: element name = "S4" seen-SQL: column header = "CITY" -SQL: columnID = "4" /> & Lt; / XSD: Sequence & gt; & Lt; / XSD: complexType & gt; & Lt; / XSD: Schema & gt;   

has been stuck here for the last 3 days

Finally I got the related solution. For my question ... and here it has been answered.

GDATXML DOCK = [[Gdataxml Document ALLO] Insightweight: [NSDATA DATAVITY ContentAffFile: Path] Encoding: NSTF 8 string encoding error: NULL];

  NSDictionary * myns = [NSDictionary dictionaryWithObjectsAndKeys: @ "Palaise: schema-Microsoft com: XML-Analysis: rowset", @ "xmlns", @ "http://www.w3.org / 2001 / XMLSchema ", @" xsd ", @" Kalash: Saw-SCL ", @" Saw-SCL ", zero]; NSArray * tempArray = [Doc nodesForXPath: @ "// xmlns: RS / XSD: schema / XSD: complexType / XSD: sequence / XSD: element" Namespace: myNS error: zero]; NSMutableArray * keyArray = [[NSMutableArray alloc] initWithCapacity: 0]; (TempArray in GDataXMLElement * columns) {GDataXMLNode * xmlElement = [column attributeForName: @ "seen-sql: columnHeading"]; // GDataXMLNode * XmlElement = [[[element2 elementsForName: @ "XSD: element"] objectAtIndex: 0] attributeForName: @ "Saw SQL: columnHeading"]; [Keyray ad object: xmlElement.stringValue]; // NSLog (@ "% @", xmlElement.stringValue); }    

No comments:

Post a Comment