Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
nodesForXPath namespace mapping
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
damian.oneill  
View profile  
 More options Nov 24 2010, 10:22 am
From: "damian.oneill" <damian.one...@gmail.com>
Date: Wed, 24 Nov 2010 07:22:22 -0800 (PST)
Local: Wed, Nov 24 2010 10:22 am
Subject: nodesForXPath namespace mapping
Hi Guys first post, apologies if this is really obvious, I looked at
the four posts that are available in the forum on this topic but I'm
not sure from these if there is a defacto solution.

First the xmlString that I am trying to parse.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><network-
element-list xmlns="http://btisystems.com/pronx/ems/schemas/
network"><network-element management-domain-name="Default" schema-
name="net_snmp" sys-name="vvx6" sys-location="&quot;proNX Host&quot;"
sys-description="Linux vvx6 2.6.35.6-45.fc14.x86_64 #1 SMP Mon Oct 18
23:57:44 UTC 2010 x86_64" sys-contact="i...@btisystems.com"
isReachable="true" time-discovered="2010-11-23T15:48:02.000Z"
version="1.28.1" class="NET-SNMP" type="WideCastOS"
address="172.27.5.106"><meta-data-list><meta-data value="" key="Postal
Code"/></meta-data-list></network-element><network-element management-
domain-name="Default" schema-name="bti704_v102" sys-name="BTI-704" sys-
location="Ottawa, Canada" sys-description="BTI Platform" sys-
contact="BTI Systems." isReachable="true" time-
discovered="2010-11-23T16:19:01.000Z" version=" 1.2" class="BTI-
DEVICE" type="BTI-704" address="172.27.7.101"><meta-data-list><meta-
data value="rt" key="Zayo"/><meta-data value="" key="Postal Code"/></
meta-data-list></network-element><network-element management-domain-
name="Default" schema-name="bti712_v102" sys-name="BTI-712" sys-
location="Ottawa, Canada" sys-description="BTI Platform" sys-
contact="BTI Systems." isReachable="true" time-
discovered="2010-11-23T16:19:02.000Z" version=" 1.2" class="BTI-
DEVICE" type="BTI-712" address="172.27.7.103"><meta-data-list><meta-
data value="" key="Postal Code"/></meta-data-list></network-
element><network-element management-domain-name="Default" schema-
name="bti704_v102" sys-name="BTI-704" sys-location="Ottawa, Canada"
sys-description="BTI Platform" sys-contact="BTI Systems."
isReachable="true" time-discovered="2010-11-23T16:19:03.000Z"
version=" 1.2" class="BTI-DEVICE" type="BTI-704"
address="172.27.7.104"><meta-data-list><meta-data value="" key="Postal
Code"/></meta-data-list></network-element><network-element management-
domain-name="Default" schema-name="bti7000_811" isReachable="true"
time-discovered="2010-11-24T14:00:37.000Z" version="8.1.1 R013"
class="BTI-DEVICE" type="BTI-7000" address="172.27.7.106"><meta-data-
list><meta-data value="" key="Postal Code"/></meta-data-list></network-
element><network-element management-domain-name="Default" schema-
name="bti7000_811" isReachable="true" time-
discovered="2010-11-24T08:42:27.000Z" version="8.1.1 C001" class="BTI-
DEVICE" type="BTI-7000" address="172.27.7.110"><meta-data-list><meta-
data value="" key="Postal Code"/></meta-data-list></network-element></
network-element-list>

As you can see the root element has a default namespace.

<network-element-list xmlns="http://btisystems.com/pronx/ems/schemas/
network">

Running the following command returns an array length of zero.

DDXMLDocument *ddDoc = [[DDXMLDocument alloc]
initWithXMLString:xmlString options:0 error:nil];
NSArray *elementNodes = [ddDoc nodesForXPath:@"//network:network-
element-list/network-element" error:&err];

Can someone tell me how I should supply the namespace to the
nodesForXPath so that I will get back a NSArray with 6 elements.

Thanks in advance,
Damian.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Loren Cahlander  
View profile  
 More options May 10 2012, 11:28 am
From: Loren Cahlander <loren.cahlan...@gmail.com>
Date: Thu, 10 May 2012 08:28:24 -0700 (PDT)
Local: Thurs, May 10 2012 11:28 am
Subject: Re: nodesForXPath namespace mapping

I am having a similar problem.

Here is a sample of the data that returns from the webservice call:

<?xml version="1.0" encoding="utf-8"?>
<IndividualMAPPResults xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://xml.assessment.com/Service/MAPPResults">
    <MAPP_Member>
        <MemberID>1234567890</MemberID>
        <FirstName>John</FirstName>
        <MiddleInitial/>
        <LastName>Doe</LastName>
        <Email>john....@example.com</Email>
        <ErrorCode>0</ErrorCode>
    </MAPP_Member>
</IndividualMAPPResults>

Here is my code:

    NSLog(@"DONE. Received Bytes: %d", [self.webdata length]);

    NSString *theXML = [[NSString alloc]

                        initWithBytes: [self.webdata mutableBytes]

                        length:[self.webdata length]

                        encoding:NSUTF8StringEncoding];

    //---shows the XML---

    NSLog(@"%@", theXML);

    NSError *err = nil;

    DDXMLDocument *document = [[DDXMLDocument alloc] initWithXMLString:theXML
options:0 error:&err];

    DDXMLElement *rootElement = [document rootElement];

    NSArray *docs=[rootElement nodesForXPath:@"//FirstName" error:&err];

    NSLog(@"Doc Count %i",[docs count]);

    for (DDXMLElement *documents in docs)

    {

        NSLog(@"First Name: %@", [documents stringValue]);

    }

I should get back an array of 1 element and it should contain "John"

Thank you,

Loren


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Loren Cahlander  
View profile  
 More options May 10 2012, 3:25 pm
From: Loren Cahlander <loren.cahlan...@gmail.com>
Date: Thu, 10 May 2012 12:25:19 -0700 (PDT)
Local: Thurs, May 10 2012 3:25 pm
Subject: Re: nodesForXPath namespace mapping

I found a workaround.  If I remove the string "xmlns=\"
http://xml.assessment.com/Service/MAPPResults\""

    theXML = [theXML stringByReplacingOccurrencesOfString:
@"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"" withString:@""];

    theXML = [theXML stringByReplacingOccurrencesOfString:
@"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" withString:@""];

    theXML = [theXML stringByReplacingOccurrencesOfString:
@"xmlns=\"http://xml.assessment.com/Service/MAPPResults\"" withString:@""];
Then the following call works:

    NSArray *docs=[rootElement nodesForXPath:@"//FirstName" error:&err];
KissXML does not like default namespaces.  This is contrary to the other
XPath processors that I use.  I consider this a bug.

Cheers,
Loren


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »