getting zero objects from the xml file in the array in iphone

前端 未结 1 705
感情败类
感情败类 2021-01-26 00:56

Hi all i am trying to use xpathQuery for the below xml data.

My xml file starts with assessmentItem. There is not even single character before assessmentItem

相关标签:
1条回答
  • 2021-01-26 01:38

    The elements you are trying to match in your XPath query are in the namespace whose URI is "http://www.imsglobal.org/xsd/imsqti_v2p1". This is because on the top-level element there is a default namespace declaration:

    xmlns="http://www.imsglobal.org/xsd/imsqti_v2p1" 
    

    To match these elements, you have two choices:

    1. define a namespace prefix for "http://www.imsglobal.org/xsd/imsqti_v2p1" and then use that prefix in your XPath expression before each element name, e.g.: "imsq:assessmentItem/imsq:itemBody/imsq:matchInteraction/imsq:simpleMatchSet/imsq:simpleAssociableChoice/imsq:p/text()"

      or

    2. modify your XPath expression to be namespace-insensitive, e.g.

      "//*[local-name() = 'simpleAssociableChoice']//text()"

    0 讨论(0)
提交回复
热议问题