NSXMLParser and duplicate tags - iphone

I have a xml file. That I want to parse with NXXMLParser. I have a basic understanding of how to use NSXMLParser but ive reached this problem were the xml file is using duplicate tags for different reasons.
The xml file looks a little like this.
<member>
<name>billy</name>
<id>1</id>
</member>
<token>
<name>login token</name>
<id>1</id>
</token>
<member>
<name>bob</name>
<id>2</id>
</member>
<token>
<name>login token</name>
<id>2</id>
</token>
Now lets say I created created 4 arrays.
memberName
memberID
tokenName
tokenID
How can I extract the data and assign it to their respective array.

Just have a state variable as a member of the delegate - when you see a "member" tag start set the state to "member", when you see a "token" tag, set the state to "token".
Then when you see the "name" and "id" tag, check the state and add it to the right array.

Related

T-SQL : getting the column descriptions into a XMLSCHEMA

I have a query where I generate a XMLSCHEMA and a XML sample.
SELECT TOP (10)
filename, queue, owner, resubmitFile,
pages, system, created, server, preflightlogs, status, kit, totalkits
FROM
Preflight_analytics
FOR XML AUTO, XMLSCHEMA ('Preflight_analytics')
All my columns have a description associated with it.
Is it possible to get the column description place inside the xsd like the below sample? I use the xsd to generate documentation and the tool I use, uses the tag <xsd:documentation> to add the description to the docs - like below:
<xsd:attribute name="JobID" fixed="" use="required">
<xsd:annotation>
<xsd:documentation xml:lang="en">Vendors unique ID</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="sqltypes:varchar" sqltypes:localeId="1033"
sqltypes:sqlCompareOptions="IgnoreCase IgnoreKanaType IgnoreWidth"
sqltypes:sqlSortId="52">
<xsd:maxLength value="50"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute
I been looking over the docs here haven't found anything yet but still looking.
Thank you
Mike

WebMethods Integration Server pub.client.soapclient changes the request element names

I have an issue with build-in (non accessible) webMethods Integration Server soapClient service. Somehow it changes the request it should send while processing it, renaming parameter items to item.
what is send to the method:
<request>
<t1>1</t1>
<operation>op</operation>
<service>1</service>
<params>
<count>1</count>
<items>
<key>12</key>
<value>12</value>
</items>
</params>
</request>
what request webmethods sends:
<request>
<t1>1</t1>
<operation>op</operation>
<service>1</service>
<params>
<count>1</count>
<item>
<key>12</key>
<value>12</value>
</item>
</params>
</request>
I'd be grateful for any workaround/idea for a solution.
I see in your example code that you first create an document named "items", then you map this document to a document list named "items". This is not valid. Please note that the pipeline in IntegrationServer is nothing but a key-value map, and the keys must be unique. That is the reason why you still have a single document named "items" instead of a document list. Rename your document to something like "item", and then use appendToDocumentList to add it to the "items" doc list.

ODK Dynamic select from database, how to handle empty list

I have an ODK form that is configured to get a list of data from the database and use that list of data for the select.
Problem is that I am not able to display an error for when the query from the database returns an empty string, instead, ODK form crashes while loading. I have tried this,
<instance id="books">
<list>
<g:if test="${Book.list()}">
<g:each in="${Book.list()}" var="book">
<book>
<id>${book.id}</id>
<name>${book.name?.encodeAsHTML()}</name>
</book>
</g:each>
</g:if>
<g:else>
<book>
<id></id>
<name></name>
</book>
</g:else>
</list>
</instance>
which creates an xml with an empty id and empty name. This makes sure that the ODK doesn't crash when it loads.
But since I don't want the user the select an empty book option, I added a constraint in the bind nodeset section,
<bind nodeset="/form/book" type="string" required="true()" constraint=". != ''" jr:constraintMsg="Book must be not be empty"/>
So now when the user tries to get past the book selection section the ODK form doesn't allow it, but instead of throwing the constraint message that I supplied it throws this error
don't know xml value! perhaps selection was stored as index only and has not yet been linked up to a formdef?

cannot insert NULL into ("ESB"."ADDRESS_API"."LABEL_NAME_MAP")

Attempting to hit the Customers end point and the API keeps rejecting my request with this extremely nondescript error:
<ErrorCode>-3002</ErrorCode>
<ErrorDesc>cannot insert NULL into ("ESB"."ADDRESS_API"."LABEL_NAME_MAP")</ErrorDesc>
<DBErrorCode>01400</DBErrorCode>
Here is the sample XML:
<?xml version='1.0' encoding='utf-8' ?>
<Add RequestId='47e1633341s4521a24e269ad12ab3f6' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://www.intuit.com/sb/cdm/v2'>
<ExternalRealmId>111111111</ExternalRealmId>
<Object xsi:type='Customer'>
<TypeOf>Organization</TypeOf>
<Name>SampleCustomer</Name>
<Address>
<Line1>123 E. Fake St</Line1>
<Line2>Suite 1</Line2>
<City>Somewhere</City>
<Country>USA</Country>
<CountrySubDivisionCode>FL</CountrySubDivisionCode>
<PostalCode>12345</PostalCode>
<Default>true</Default>
<Tag>Billing</Tag>
</Address>
<Phone>
<DeviceType>LandLine</DeviceType>
<FreeFormNumber>123-456-4563</FreeFormNumber>
<Default>true</Default>
<Tag>Main</Tag>
</Phone>
<DBAName>Sample Customer</DBAName>
<AcctNum>51f2ce86134c03000a000155</AcctNum>
</Object>
</Add>
Any suggestions? These exceptions are super confusion. I found the one related to "ESB"."PHONE_API"."LABEL_NAME_MAP" was related to an empty phone number field. That isn't the case with this request.
You edited your post to reflect a correct tag, so this answer may no longer be relevant
My first guess would be that, per the documentation, the Address/Tag node allowable values are defined by the PhysicalAddressLabelType enum.
Tag - String - Tag (or label) that identifies the use of the address. The
values allowed are defined in the PhysicalAddressLabelType.
If you look at the allowable values, you'll see the only allowable values are:
Billing
Shipping
But you specified:
Office
Can you try specifying a valid value?
Likewise, you're specifying an invalid Tag for the Phone node as well. The allowable values are here:
https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/v2/0500_quickbooks_windows/062_enumerations/telephonenumberlabeltype
But you've specified:
Main
Can you try specifying a valid value?

iPhone: How to handle Core Data relationships

I'm new to Core Data and databases in general. Now I need to parse a XML and store the contents in Core Data. The XML looks something like this:
<books>
<book id="123A" name="My Book">
<page id="95D" name="Introduction">
<text id="69F" type="header" value="author text"/>
<text id="67F" type="footer" value="author text"/>
</page>
<page id="76F" name="Chapter 1">
<text id="118" type="selection">
<value data="1">value1</value>
<value data="2">value2</value>
<value data="3">value3</value>
</text>
</page>
</book>
<book id="124A"...
From my understanding I would need four Entities, like "Books", "Book", "Pages" and "Text". I wonder how to set the relationships correctly and how to add for example a Page object to a Book object and how to retrieve a Text object attribute's value? The tutorials I have found mostly deal with one Entity so I didn't really get the idea.. Gtrateful for any help!
No, you'd need three entities. You can think of "Books" as the CoreData database you're using. The CoreData database then includes a number of entities called book.
I think the data model you have is a bit weird, but I guess it makes sense for your application. To map it to CoreData I would:
Add the entities Book, Page, Text
Add a bookId, pageId, textId to them, respectively.
Then add a relation from Page to Book, and from Text to Page.
By then you should be able to print out a whole book by asking for all Pages that have
Book = the book you're interested in
and then order all those Pages by their pageId
and in order, ask for all texts that have
Page = the current page
then order those Texts by their textId.
What might be a problem is that a Text can have multiple Values, as seen in your XML above. You could use this by adding another entity called Value, but I would probably solve it by adding the attributes "value" and "type" to the Text entity directly. (You could then use "value" as a second sort key when printing out a page.
Check out these links:
http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/CoreData/
http://developer.apple.com/cocoa/coredatatutorial/index.html (for regular Cocoa, but the same principles hold so this should help)