I have a simple question.
Let's say I have a pList that contains 1 string and 2 arrays. Each Array has 100 elements.
Is there a way to load only 1 of the 2 arrays without loading the entire pList into memory ?
Thanks a lot.
The plist is a XML format text file. So, you can parse the file by XML parser with SAX manner. The sample code XMLPerformance includes a good example about libxml which parses data with SAX manner.
Related
I try to add a thumbnail to a JPEG picture using libexif.
For now I'm borrowing the code from exif (the command line tool that is shipped by the libexif team).
However I noticed the XMP tags get deleted from the metadata. There is an old bugreport here.
I tried to see how to achieve this anyway with libexif but I don't really understand how to get the XMP from input file and put it in the output file. I just want to copy all XMP data, I don't need to extract anything of it.
I saw there is a TAG EXIF_TAG_XML_PACKET in exif_tag.h but couldn't figure out how to read/write this tag.
A related solution is in this SO answer but it looks complicated. I'm not familiar coding in C.
Is it actually possible to keep all XMP when using only libexif API? Have things changed in recent years on that? How would you write this in code?
Thanks
I believe it should be somewhat straightforward. XMP fields are described in the ISO/Adobe standard. Regular Kotlin/Java/Android file I/O and some string manipulation should be all that is required.
I would start out by becoming intimately familiar with ISO 16684-1:2019. Then, write a method for your jpeg file class that grabs all the XMP fields. Store those fields in a temp file (to prevent difficult to recover data loss in the event of your code or libexif crashing). Hand the file off to libexif. Generate the thumbnail. Finally, when that's done you can restore the XMP fields. If the thumbnail is stored in an XMP field as well (and it sounds like it is), it may be easier to concatenate that field with the other ones which were already grabbed, updating the temp file so that it contains EVERY XMP field, before adding all of the XMP fields back to the jpeg.
Unfortunately, I do not currently have the time to read a 50 page ISO standard, synthesize the information, and then write the code to implement the solution. Here's a link to the standard at least, to get you started.
https://www.iso.org/obp/ui/#iso:std:iso:16684:-1:ed-2:v1:en
I want to compare two XML documents to find and show where is the difference
like diff utility in XCode.
I can retrieve and parse xml code using NSXMLParser in basic level,
and can tell 'they are not exactly same'
but I don't know how to tell 'where and which'.
Is there any open-source based library for this?
Thanks in advance.
Try following link
XML Documents
also try this
i have a xml file on a server that look for example like this one:
<breakfast_menu>
<food>
<name>Belgian Waffles</name>
<price>$5.95</price>
<description>two of our famous Belgian Waffles with plenty of real maple syrup</description>
<calories>650</calories>
</food>
<food>
<name>Strawberry Belgian Waffles</name>
<price>$7.95</price>
<description>light Belgian waffles covered with strawberries and whipped cream</description>
<calories>900</calories>
</food>
</breakfast_menu>
i need xml parser that will parse it and enter each one of them to a class that for examle will called food(and have 4 parameters : name,price,.....).
and finally to create an array of the classes that he create.there is built xml parser that do it?
Here are some sources on the topic:
Navigating XML from Objective-C
How do I parse an NSString containing XML in Objective-C?
Objective C: Parsing an XML file
Parsing XML in Cocoa
Parsing XML in objective-c
For learning to parse xml, look at the links Brandon provided. Your requirement to build an array of classes from xml is something you'll need to create yourself.
A suggestion I have for you is instead of creating classes, just put the data into a NSMutableArray. The array will contain NSDictionary objects for food sub-items.
I have a large amount of data in an XML file, and I'd like to append data to this file without rewriting it every time. I already know how to write the entire file out, but I'm struggling with how to append data to this file. Do you have a suggestion for how to do this?
XML isn't a good format for this - if you append to a previously-complete document, it's no longer a complete document.
One option (depending on the APIs available to you) is not to write the root tag or document declaration, but to fake them when you read the file. So you'd have:
Fake document declaration
Fake root open tag
Real data from the file
Fake root close tag
Then you can just append elements to the end of your file at will. It will depend on what you're trying to do with this file though - and whether you can fake a stream input which effectively "tops and tails" the real data in the file.
I am new to XML parsing. I am parsing the following XML. There are tutorials for if XML has unique attributes but this XML has repeating attributes.
<?xml version="1.0" encoding="utf-8"?>
<start>
<Period periodType="A" fYear="2005" endCalYear="2005" endMonth="3">
<ConsEstimate type="High">
<ConsValue dateType="CURR">-8.9919</ConsValue>
</ConsEstimate>
<ConsEstimate type="Low">
<ConsValue dateType="CURR">-13.1581</ConsValue>
</ConsEstimate>
</Period>
< Period periodType="A" fYear="2006" endCalYear="2006" endMonth="3">
<ConsEstimate type="High">
<ConsValue dateType="CURR">-100.000</ConsValue>
</ConsEstimate>
<ConsEstimate type="Low">
<ConsValue dateType="CURR">-13.1581</ConsValue>
</ConsEstimate>
</Period>
</start>
I need to fetch the low and high values based on the years 2005 and 2006.
I agree with SB's comment, if you wan't to handle xml-datastructurse, you should know at least the basic stuff.
A good tutorial i can reccomend is ww3 schools XML Tutorial
once you did that, you should know that there are several ways to parse xml files. For flatfiles i recommend to use the TBXML Library, it is really fast and easy to handle within your code.