Search Results

Search found 18472 results on 739 pages for 'vtd xml author'.

Page 84/739 | < Previous Page | 80 81 82 83 84 85 86 87 88 89 90 91  | Next Page >

  • Two AJAX asynchronus GET call: Only one get the xml file

    - by Woho87
    Hi! I have two AJAX GET calls that are set to asynchcronus = true; I want to obtain two XML files on my server. The two AJAX calls and rendering are defined in function foo & koo. And are called simultaneously. function foo(){ var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function(){ if(xmlhttp.readyState == 4 && xmlhttp.status == 200){ var xmlDoc = xmlhttp.responseXML; //Do something } } xmlhttp.open('get', 'url', true); xmlhttp.send(); } function koo(){ //Almost the same as function foo } foo(); koo(); I've noticed that inside the if statement in the first function call(foo), the code their will never compile. While in the second function call(koo). The code inside the if statement can be compiled. If I set both asynchronus to false, then there is no problem at all. If I remove the second function call(koo) from the code, than the code inside the if statement can be compiled. What can I do to have both asynchronus AJAX calls?

    Read the article

  • Processing XML comments in order using SAX & Cyberneko

    - by Joel
    I'm using cyberneko to clean and process html documents. I need to be able to process all the comments that occur in the original html documents. I've configured the cyberneko sax parser to process comments like so: parser.setProperty("http://xml.org/sax/properties/lexical-handler", consumer); ...using the same consumer as I am for DOM events. I get a callback for each of the comments: @Override public void comment(char[] arg0, int arg1, int arg2) throws SAXException { System.out.println("COMMENT::: "+new String(arg0, arg1, arg2)); } The problem I have is that all the comments are processed first, out of context of the DOM. i.e. I get a callback for all the comments before the document head, body etc.... What I'd like is for the comment callbacks to occur in the order they occur in the DOM. Edit: what I'm actually trying to do is parse the instructions for IE in the original html, such as: <!--[if lte IE 6]><body class="news ie"><![endif]--> At the moment they are all dropped, I need to include them in the cleaned HTML document.

    Read the article

  • Modify attribute of certain XML elements

    - by hgpc
    I would like to modify an attribute of a very long xml like this: <element index="0"> <subelement bla="asdf" /> <subelement bla="asdf" /> </element> <element index="1"> <subelement bla="asdf" /> <subelement bla="asdf" /> </element> ... I need to add N the value of each index attribute. Say N=5. The result would be: <element index="5"> <subelement bla="asdf" /> <subelement bla="asdf" /> </element> <element index="6"> <subelement bla="asdf" /> <subelement bla="asdf" /> </element> ... What's the easiest way to do this? I presume it would be with XSLT, but I don't know how to do it. Thanks!

    Read the article

  • XSD problem: The value of attribute on element is not valid with respect to its type

    - by Tom Brito
    (First of all, I'm trying to learn how to handle xsd files, I know very little) I got this xsd, and just copy to Eclipse IDE, and it says there an error on line 26: <xs:element name="Issuer" type="dkx:IssuerType" /> saying: cvc-attribute.3: The value 'dkx:IssuerType' of attribute 'type' on element 'xs:element' is not valid with respect to its type, 'QName'. Any idea what is this? (as this is an example file, I'm assuming it is an independent file, hope it is)

    Read the article

  • Counting XML elements in file on Android

    - by CSharperWithJava
    Take a simple XML file formatted like this: <Lists> <List> <Note/> ... <Note/> </List> <List> <Note/> ... <Note/> </List> </Lists> Each node has some attributes that actually hold the data of the file. I need a very quick way to count the number of each type of element, (List and Note). Lists is simply the root and doesn't matter. I can do this with a simple string search or something similar, but I need to make this as fast as possible. Design Parameters: Must be in java (Android application). Must AVOID allocating memory as much as possible. Must return the total number of Note elements and the number of List elements in the file, regardless of location in file. Number of Lists will typically be small (1-4), and number of notes can potentially be very large (upwards of 1000, typically 100) per file. I look forward to your suggestions.

    Read the article

  • Recursive search Linq to xml

    - by Raj Esh
    this is my sample xml. <Messages> <Conversation> <id>Z100</id> <ReplyToId></ReplyToId> <Message>Topic</Message> </Conversation> <Conversation> <id>A100</id> <ReplyToId></ReplyToId> <Message>This is a test</Message> </Conversation> <Conversation> <id>M100</id> <ReplyToId>A100</ReplyToId> <Message>What kind of test</Message> </Conversation> <Conversation> <id>A200</id> <ReplyToId>M100</ReplyToId> <Message>Stage 1</Message> </Conversation> <Conversation> <id>M200</id> <ReplyToId>A200</ReplyToId> <Message>Test result for </Message> </Conversation> </Messages> How to get the conversation list based on id using linq in C#. Say for example, If i want to get the conversation for id "A100" which has a link to other conversation based on ReplyToid.

    Read the article

  • Change Sequence to Choice

    - by Gordon
    In my Schema File I defined a Group with a Sequence of possible Elements. <group name="argumentGroup"> <sequence> <element name="foo" type="double" /> <element name="bar" type="string" /> <element name="baz" type="integer" /> </sequence> </group> I then reference this Group like this: <element name="arguments"> <complexType> <group ref="my:argumentGroup"/> </complexType> </element> Is it possible to reference the Group at some other point but restrict it so it's a Choice instead of a Sequence. The position where I want to reuse it would only allow one of the Elements within. <element name="argument" minOccurs="0" maxOccurs="1"> <complexType> <group name="my:argumentGroup"> <! -- Somehow change argumentGroup sequence to choice here --> </group> <complexType> </element>

    Read the article

  • Android xml Array returning 0 for getIndexCount()

    - by user1459976
    i'm storing data in an xml array in this fashion <resources> <array name="myarray"> <item> <item>attribute1</item> <item>attribute2</item> <item>and so on</item> </item> <item> <item>attribute1</item> <item>attribute2</item> <item>and so on</item> </item> <item> <item>attribute1</item> <item>attribute2</item> <item>and so on</item> </item> </array> </resources> // in program TypedArray array = getResources().obtainTypedArray(R.array.myarray); when i call array.getIndexCount() in the program it returns 0, what is wrong?

    Read the article

  • Xml output on HTML

    - by umitunal
    Hi, My xml data = &lt;Item "/api/items/4000000002011"&gt;&lt;ItemID&gt;4000000002011&lt;/ItemID&gt;&lt;Name&gt;Sample Item1&lt;/Name&gt;&lt;Description&gt;Sample Description&lt;/Description&gt;&lt;Rate&gt;34.00&lt;/Rate&gt;&lt;Tax1Name&gt;PST&lt;/Tax1Name&gt;&lt;Tax1Percentage&gt;8&lt;/Tax1Percentage&gt;&lt;Tax2Name/&gt;&lt;Tax2Percentage/&gt;&lt;/Item&gt; Html output=<Item uri="/api/items/4000000002011"> <ItemID>4000000002011</ItemID><Name>Sample Item1</Name><Description>Sample Description</Description><Rate>34.00</Rate><Tax1Name>PST</Tax1Name><Tax1Percentage>8</Tax1Percentage><Tax2Name/><Tax2Percentage/></Item> I want to html output.How do I? <Item "/api/items/4000000002011"> <ItemID>4000000002011</ItemID> <Name>Sample Item1</Name> <Description>Sample Description</Description> <Rate>34.00</Rate> <Tax1Name>PST</Tax1Name> <Tax1Percentage>8</Tax1Percentage> <Tax2Name/> <Tax2Percentage/> </Item>

    Read the article

  • Sorting XML file by attribute

    - by LibraRocks
    Hi, I have a following XML code: <Group> <GElement code="x"> <Group> <GElement code="x"> <fname>a</fname> <lname>b</lname> </GElement> <GElement code ="f"> <fname>fa</fname> </GElement> </Group> </GElement> <GElement code ="f"> </GElement> </Group> I would like to have the output sorted by "code" like: <Group> <GElement code ="f"> </GElement> <GElement code="x"> <Group> <GElement code ="f"> <fname>fa</fname> </GElement> <GElement code="x"> <fname>a</fname> <lname>b</lname> </GElement> </Group> </GElement> </Group> The depth of the tree can be endless i.e. the GElement can have another Group and so on. Any ideas?

    Read the article

  • Strange behaviour when collapsing lines in XML bound WPF Datagrid

    - by Flossn
    i am using a wpf datagrid with a xml file as DataContext. All working good except for iterating thorough the table and collapsing individual rows. There are several checkboxes where the user can decide which kinds of rows he wants to see, dependent on their error level string. If a checkbox is checked, some of the rows are collapsed, others not. You need to uncheck the checkbox and check it again to collapse the ones of the first try and some of the others. If you recheck it again more rows are collapsed every time. I guess it has something to do with how much of the list is actually visible and how much not because of the window size. Thanks in advance. foreach (DataGridRow r in rows) { bool showRow = true; var tb = Datagrid.GetCell(dataGridEvents, r, 2).Content; string level = ((TextBlock)tb).Text; switch (level) { case "Warning": showRow = checkBoxWarnings.IsChecked.HasValue ? checkBoxWarnings.IsChecked.Value : false; break; case "Critical": showRow = checkBoxCritical.IsChecked.HasValue ? checkBoxCritical.IsChecked.Value : false; break; case "OK": showRow = checkBoxOK.IsChecked.HasValue ? checkBoxOK.IsChecked.Value : false; break; case "Unknown": showRow = checkBoxUnknown.IsChecked.HasValue ? checkBoxUnknown.IsChecked.Value : false; break; } r.Visibility = showRow ? Visibility.Visible : Visibility.Collapsed; }

    Read the article

  • Is there any way to get Visual Studio 2008 to update .net style comments automatically?

    - by Jon Cage
    I've been writing a lot of VC++ 2008 / CLI software recently and am using the C#/CLI style documentation: /// <summary> /// Function the does stuff /// </summary> /// <param name="someParam">Specifies some option</param> /// <returns>true if it worked</returns> bool DoStuff( bool someParam ); I find myself re-typing those blocks quite frequently and frankly, it's getting repetitive. Is there any way to get Visual Studio to create / update those blocks automatically as you create new function definitions or update existing definitions?

    Read the article

  • Insert Into Two SQL Tables From XML Maintaining Relationship

    - by Thx
    I am looking to insert records from xml into two different tables. For example <Root> <A> <AValue>1</AValue> <Children> <B> <BValue>2</BValue> </B> </Children> </A> </Root> Would insert a record into table A AID AValue # 1 also insert a record into table B BID AID BValue # #(Same as AID Above) 2 I have this DECLARE @idoc INT DECLARE @doc NVARCHAR(MAX) SET @doc = ' <Root> <A> <AValue>1</AValue> <Children> <B> <BValue>2</BValue> </B> </Children> </A> </Root> ' EXEC sp_xml_preparedocument @idoc OUTPUT, @doc CREATE TABLE #A ( AID INT IDENTITY(1, 1) , AValue INT ) INSERT INTO #A SELECT * FROM OPENXML (@idoc, '/Root/A',2) WITH (AValue INT ) CREATE TABLE #B ( BID INT IDENTITY(1, 1) , AID INT , BValue INT ) INSERT INTO #B SELECT * FROM OPENXML (@idoc, '/Root/A/Children/B',2) WITH ( AID INT, BValue INT ) SELECT * FROM #A SELECT * FROM #B DROP TABLE #A DROP TABLE #B Thanks!

    Read the article

  • How do I make a serilaization class for this?

    - by chobo2
    Hi I have something like this(sorry for the bad names) <root> <product></product> <SomeHighLevelElement> <anotherElment> <lowestElement> </lowestElement> </anotherElment> </SomeHighLevelElement> </root> I have something like this for my class public class MyClass { public MyClass() { ListWrapper= new List<UserInfo>(); } public string product{ get; set; } public List<SomeHighLevelElement> ListWrapper{ get; set; } } public class SomeHighLevelElement { public string lowestElement{ get; set; } } But I don't know how to write the code for the "anotherElement" not sure if I have to make another wrapper around it.

    Read the article

  • Parse particular text from an XML string

    - by Dan Sewell
    Hi all, Im writing an app which reads an RSS feed and places items on a map. I need to read the lat and long numbers only from this string: http://www.xxxxxxxxxxxxxx.co.uk/map.aspx?isTrafficAlert=true&lat=53.647351&lon=-1.933506 .This is contained in link tags Im a bit of a programming noob but im writing this in C#/Silverlight using Linq to XML. Shold this text be extrated when parsing or after parsing and sent to a class to do this? Many thanks for your assistance. EDIT. Im going to try and do a regex on this this is where I need to integrate the regex somewhere in this code. I need to take the lat and long from the Link element and seperate it into two variables I can use (the results are part of a foreach loop that creates a list.) var events = from ev in document.Descendants("item") select new { Title = (ev.Element("title").Value), Description = (ev.Element("description").Value), Link = (ev.Element("link").Value), }; Question is im not quite ure where to put the regex (once I work out how to use the regex properly! :-) )

    Read the article

  • jquery XML .html() instead of .text() is not displaying?

    - by Xtian
    I can't seem to figure out this problem. I am trying to get xml to render html tags. The problem I am having using .text() will display but not recognize any html tags. If I use .html() or just call var long2 = $(this).find('long'); nothing will show up in Safari or IE. I have xml paragraph I have text in here that needs bold tags or tags which is why i need html tags in the xml to be recognized. Code: $(document).ready(function(){ $.ajax({ type: "GET", url: "xml/sites.xml", dataType: "xml", success: function(xml) { $(xml).find('site').each(function(){ var id = $(this).attr('id'); var title = $(this).find('title').text(); var Class = $(this).find('class').text(); $('<div class="'+Class+'" id="link_'+id+'"></div>').html('<p class="title">'+title+'</p>').appendTo('#page-wrap'); $(this).find('desc').each(function(){ var url = $(this).find('url').text(); var long = $(this).find('long').text(); $('<div class="long"></div>').html(long).appendTo('#link_'+id); $('#link_'+id).append('<a href="http://'+url+'">'+url+'</a>'); var long2 = $(this).find('long'); $('<div class="long2"></div>').html(long2).appendTo('#link_'+id); }); }); } });

    Read the article

  • Counting unique XML element attributes using XSLT

    - by patrick_corrigan
    I've just started using XSLT and am trying to figure this out. Your help would be greatly appreciated. Example XML file <purchases> <item id = "1" customer_id = "5"> </item> <item id = "2" customer_id = "5"> </item> <item id = "7" customer_id = "4"> </item> </purchases> Desired HTML Output: <table> <tr><th>Customer ID</th><th>Number of Items Purchased</th></tr> <tr><td>5</td><td>2</td></tr> <tr><td>4</td><td>1</td></tr> </table> Customer with id number 5 has bought 2 items. Customer with id number 4 has bought 1 item.

    Read the article

  • How to transform huge xml files in java?

    - by fx42
    As the title says it, I have a huge xml file (GBs) <root> <keep> <stuff> ... </stuff> <morestuff> ... </morestuff> </keep> <discard> <stuff> ... </stuff> <morestuff> ... </morestuff> </discard> </root> and I'd like to transform it into a much smaller one which retains only a few of the elements. My parser should do the following: 1. Parse through the file until a relevant element starts. 2. Copy the whole relevant element (with children) to the output file. go to 1. step 1 is easy with SAX and impossible for DOM-parsers. step 2 is annoying with SAX, but easy with the DOM-Parser or XSLT. so what? - is there a neat way to combine SAX and DOM-Parser to do the task?

    Read the article

  • Not able to transform my xml to other xml

    - by vineet
    Input XML <?xml version="1.0" encoding="UTF-8" ?> <Z_RFC_SP_POTEXT_OUT > <ZMPO_TXT> <item> <LIFNR>0009002008</LIFNR> <ZPOTEXT1>BSE-TSE Statement document is accpeted by [email protected] on 2010-04-12</ZPOTEXT1> <ZPOTEXT2 /> <FLAG /> </item> <item> <LIFNR>0009002008</LIFNR> <ZPOTEXT1>Ist Part</ZPOTEXT1> <ZPOTEXT2 /> <FLAG /> </item> <item> <LIFNR>0009002008</LIFNR> <ZPOTEXT1>2nd Part</ZPOTEXT1> <ZPOTEXT2 /> <FLAG /> </item> <item> <LIFNR>0009000013</LIFNR> <ZPOTEXT1>vComments for Obj 1hkshkshdiswyidswyidyswidysiysiysskhskchskhckchk</ZPOTEXT1> <ZPOTEXT2 /> <FLAG /> </item> <item> <LIFNR>0009000017</LIFNR> <ZPOTEXT1>vComments for Obj 1hkshkshdiswyidswyidyswidysiysiysskhskchskhckchk</ZPOTEXT1> <ZPOTEXT2 /> <FLAG /> </item> <item> <LIFNR>0009000017</LIFNR> <ZPOTEXT1>1st part</ZPOTEXT1> <ZPOTEXT2 /> <FLAG /> </item> <item> <LIFNR>0009000017</LIFNR> <ZPOTEXT1>2nd part</ZPOTEXT1> <ZPOTEXT2 /> <FLAG /> </item> <item> <LIFNR>0009000022</LIFNR> <ZPOTEXT1>INCLUDE ZPTP_TERMS_AND_CONDITIONS_2003 OBJECT TEXT ID ST</ZPOTEXT1> <ZPOTEXT2 /> <FLAG /> </item> <item> <LIFNR>0009000026</LIFNR> <ZPOTEXT1>INCLUDE ZPTP_TERMS_AND_CONDITIONS_2003 OBJECT TEXT ID ST</ZPOTEXT1> <ZPOTEXT2 /> <FLAG /> </item> </ZMPO_TXT> </Z_RFC_SP_POTEXT_OUT> I am looking for the output <?xml version="1.0" encoding="UTF-8" ?> <Z_RFC_SP_POTEXT_OUT > <ZMPO_TXT> <item> <LIFNR>0009002008</LIFNR> <ZPOTEXT1>BSE-TSE Statement document is accpeted by [email protected] on 2010-04-12 Ist Part 2nd Part</ZPOTEXT1> <ZPOTEXT2 /> <FLAG /> </item> <item> <LIFNR>0009000013</LIFNR> <ZPOTEXT1>vComments for Obj 1hkshkshdiswyidswyidyswidysiysiysskhskchskhckchk</ZPOTEXT1> <ZPOTEXT2 /> <FLAG /> </item> <item> <LIFNR>0009000017</LIFNR> <ZPOTEXT1>vComments for Obj 1hkshkshdiswyidswyidyswidysiysiysskhskchskhckchk 1st part 2nd part</ZPOTEXT1> <ZPOTEXT2 /> <FLAG /> </item> <item> <LIFNR>0009000022</LIFNR> <ZPOTEXT1>INCLUDE ZPTP_TERMS_AND_CONDITIONS_2003 OBJECT TEXT ID ST</ZPOTEXT1> <ZPOTEXT2 /> <FLAG /> </item> <item> <LIFNR>0009000026</LIFNR> <ZPOTEXT1>INCLUDE ZPTP_TERMS_AND_CONDITIONS_2003 OBJECT TEXT ID ST</ZPOTEXT1> <ZPOTEXT2 /> <FLAG /> </item> </ZMPO_TXT> </Z_RFC_SP_POTEXT_OUT> Can any one help me out how to do that using xslt. Its very urgent Thanks Vineet

    Read the article

  • Flex barChart and XML Data

    - by theband
    <Projectlist> <Project> <ProjectName>Alcoswitch - ToggleSwitches </ProjectName> <ProjectStatusname>Planning</ProjectStatusname> </Project> <Project> <ProjectName> Transverse Wedge</ProjectName> <ProjectStatusname>Canceled</ProjectStatusname> </Project> <Project> <ProjectName>High Speed Pluggable I/O</ProjectName> <ProjectStatusname>In-Progress</ProjectStatusname> </Project> <Project> <ProjectName>"High Speed Pluggable I/O - Product Breakouts:</ProjectName> <ProjectStatusname>In-Progress</ProjectStatusname> </Project> <Project> <ProjectName>Circular Plastic Connector (CPC)</ProjectName> <ProjectStatusname>In-Progress</ProjectStatusname> </Project> </Projectlist> This is my XML data i am recieving, how can i show this in a bar chart. <mx:BarChart id="barChart" showDataTips="true" dataProvider="{ProjectStateInfo}" width="100%" height="100%"> <mx:horizontalAxis> <mx:CategoryAxis categoryField="ProjectStatusname"/> </mx:horizontalAxis> <mx:verticalAxis> <mx:CategoryAxis categoryField="ProjectName"/> </mx:verticalAxis> <mx:series> <mx:BarSeries id="barSeries" visible="true" yField="ProjectName" xField="ProjectStatusname" displayName="ProjectStatusname" /> </mx:series> </mx:BarChart> My X-Axis shows muliple values of In-Progress, but i just need one. Is it possible to represent such relationship using BarChart. Any other Flex chart is Advisable.

    Read the article

  • Parsing XML with VB.net.

    - by SuperFurryToad
    I'm trying to make sense of a big data dump of XML that I need to write to a database using some VB.net code. I'm looking for some help getting started with the parsing code, specifically how to access the attribute values. <Product ID="523233" UserTypeID="Property" ParentID="523232"> <Name>My Property Name</Name> <AssetCrossReference AssetID="173501" Type=" Non Print old"> </AssetCrossReference> <AssetCrossReference AssetID="554740" Type=" Non Print old"> </AssetCrossReference> <AssetCrossReference AssetID="566495" Type=" Non Print old"> </AssetCrossReference> <AssetCrossReference AssetID="553014" Type="Non Print"> </AssetCrossReference> <AssetCrossReference AssetID="553015" Type="Non Print"> </AssetCrossReference> <AssetCrossReference AssetID="553016" Type="Non Print"> </AssetCrossReference> <AssetCrossReference AssetID="553017" Type="Non Print"> </AssetCrossReference> <AssetCrossReference AssetID="553018" Type="Non Print"> </AssetCrossReference> <Values> <Value AttributeID="5115">Section of main pool</Value> <Value AttributeID="5137">114 apartments, four floors, no lifts</Value> <Value AttributeID="5170">Property location</Value> <Value AttributeID="5164">2 key</Value> <Value AttributeID="5134">A comfortable property, the apartment is set on a pine-covered hillside - a scenic and peaceful location.</Value> <Value AttributeID="5200">YYY</Value> <Value AttributeID="5148">facilities include X,Y,Z</Value> <Value AttributeID="5067">Self Catering. </Value> <Value AttributeID="5221">Frequent organised daytime activities</Value> </Values> </Product> </Product> Thanks in advance for your help.

    Read the article

  • remove xml tags with XSLT

    - by azathoth
    Hello all I have the following xml file: <xfa:data> <form1> <Page1> <Page2> <contractInfo> ... </contractInfo> <paymentInfo> ... </paymentInfo> </form1> <commercialType> .... </commercialType> <userList> ... </userList> <officesList> ... </officesList> <commercialType> .... </commercialType> <userList> ... </userList> <officesList> ... </officesList> <commercialType> .... </commercialType> <userList> ... </userList> <officesList> ... </officesList> </xfa:data> I want to remove every ocurrence of the commercialType, userList and officesList nodes, so my output would be : <xfa:data> <form1> <Page1> <Page2> <contractInfo> ... </contractInfo> <paymentInfo> ... </paymentInfo> </form1> </xfa:data> How could I do that using XSLT? Thank you

    Read the article

  • Two unordered list from this XML data

    - by Daniel
    Hi I have this XML: <Tekstside id="1081" level="3" nodeName="Test" urlName="test"> <umbracoRedirect /> <overskrift>Test</overskrift> <tekst></tekst> <sidensTitel /> <sidensBeskrivelse /> <sidensNgleord /> - <Faktaboks id="1113" level="4" nodeName="Det her virker" urlName="det-her-virker"> <umbracoNaviHide>1</umbracoNaviHide> - <fordele> - <values> <value>Ingen emission</value> <value>Det virker bare</value> <value>Det er top nice</value> <value>Det er bare fedt</value> <value>Udstødnings</value> <value /> </values> </fordele> - <ulemper> - <values> <value>Giver sygdom</value> <value>Er farligt</value> <value /> </values> </ulemper> </Faktaboks> </Tekstside> I want the "fordele" values and the "ulemper" values made into the unorderes lists with XSLT in Umbraco: <div class="fanda"> <ul class="for"> <li>Købsprisen</li> </ul> <ul class="against"> <li>Kortere servicerings interval pga. additivet fylder med i filteret.</li> <li>Der kan forekomme meget varieret modtryk, isærpå biler med lav - udstødningstemperatur.</li> <li>Udgifter til Additiv - typisk fra 400 - 600 kr. pr. liter.</li> <li>Kan ikke klare alle kørselsmønstre</li> </ul> </div>

    Read the article

  • Adding objects to an NSMutableArray, order seems odd when parsing from an XML file

    - by diatrevolo
    Hello: I am parsing an XML file for two elements: "title" and "noType". Once these are parsed, I am adding them to an object called aMaster, an instance of my own Master class that contains NSString variables. I am then adding these instances to an NSMutableArray on a singleton, in order to call them elsewhere in the program. The problem is that when I call them, they don't seem to be on the same NSMutableArray index... each index contains either the title OR the noType element, when it should be both... can anyone see what I may be doing wrong? Below is the code for the parser. Thanks so much!! #import "XMLParser.h" #import "Values.h" #import "Listing.h" #import "Master.h" @implementation XMLParser @synthesize sharedSingleton, aMaster; - (XMLParser *) initXMLParser { [super init]; sharedSingleton = [Values sharedValues]; aMaster = [[Master init] alloc]; return self; } - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict { aMaster = [[Master alloc] init]; //Extract the attribute here. if ([elementName isEqualToString:@"intro"]) { aMaster.intro = [attributeDict objectForKey:@"enabled"]; } else if ([elementName isEqualToString:@"item"]) { aMaster.item_type = [attributeDict objectForKey:@"type"]; //NSLog(@"Did find item with type %@", [attributeDict objectForKey:@"type"]); //NSLog(@"Reading id value :%@", aMaster.item_type); } else { //NSLog(@"No known elements"); } //NSLog(@"Processing Element: %@", elementName); //HERE } - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { if(!currentElementValue) currentElementValue = [[NSMutableString alloc] initWithString:string]; else { [currentElementValue appendString:string];//[tempString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]]; CFStringTrimWhitespace((CFMutableStringRef)currentElementValue); } } - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { if ([elementName isEqualToString:@"item"]) { [sharedSingleton.master addObject:aMaster]; NSLog(@"Added %@ and %@ to the shared singleton", aMaster.title, aMaster.noType); //Only having one at a time added... don't know why [aMaster release]; aMaster = nil; } else if ([elementName isEqualToString:@"title"]) { [aMaster setValue:currentElementValue forKey:@"title"]; } else if ([elementName isEqualToString:@"noType"]) { [aMaster setValue:currentElementValue forKey:@"noType"]; //NSLog(@"%@ should load into the singleton", aMaster.noType); } NSLog(@"delimiter"); NSLog(@"%@ should load into the singleton", aMaster.title); NSLog(@"%@ should load into the singleton", aMaster.noType); [currentElementValue release]; currentElementValue = nil; } - (void) dealloc { [aMaster release]; [currentElementValue release]; [super dealloc]; } @end

    Read the article

  • Restructuting XML Data

    - by Frank
    Hi! The following is an excerpt of my XML data source: <file> <ALL_INSTANCES> <instance> <ID>1</ID> <start>5.8633333333</start> <end>29.8216666667</end> <code>Player 1</code> </instance> <instance> <ID>2</ID> <start>28.4566666667</start> <end>51.1450000000</end> <code>Player 2</code> </instance> <instance> <ID>3</ID> <start>49.8383333333</start> <end>71.1150000000</end> <code>Player 3</code> </instance> <instance> <ID>4</ID> <start>72.9850000000</start> <end>95.3766666667</end> <code>Speler 1</code> </instance> </ALL_INSTANCES> I'm looking to restructure this data into something like this: <Player 1> <ID>1</ID> <start>5.8633333333</start> <end>29.8216666667</end> </Player 1> <Player 1> <ID>4</ID> <start>72.9850000000</start> <end>95.3766666667</end> </Player 1> <Player 2> <ID>2</ID> <start>28.4566666667</start> <end>51.1450000000</end> </Player 2> <Player 3> <ID>3</ID> <start>49.8383333333</start> <end>71.1150000000</end> </Player 3> Could anyone please help me to achieve this? Much appreciated! Cheers, Frank

    Read the article

< Previous Page | 80 81 82 83 84 85 86 87 88 89 90 91  | Next Page >