Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8655293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:59:31+00:00 2026-06-12T14:59:31+00:00

<scxml xmlns=http://www.w3.org/2005/07/scxml version=1.0 profile=ecmascript initial=idle> <state id=idle> <transition event=mousedown target=dragging/> </state> <state id=dragging> <transition

  • 0
<scxml 
xmlns="http://www.w3.org/2005/07/scxml"
version="1.0"
profile="ecmascript"
initial="idle">

<state id="idle">
    <transition event="mousedown" target="dragging"/>
</state>

<state id="dragging">
    <transition event="mouseup" target="idle"/>
    <transition event="mousemove" target="dragging"/>
</state>

</scxml>

I want to parse this xml when i start the application i enter the initial state that is “idle” then when my event completed i want to move the next state “dragging”. how can i do this?

I am using NSXmlparser in the following method.

-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{
if ([elementName isEqualToString:@"scxml"])

{
    stateID = [attributeDict objectForKey:@"initital"];
    stateInfo = [[StateInfo alloc]initWithStateName:stateID];
    return;

}
if ([elementName isEqualToString: @"state"] ){

    if ([[attributeDict objectForKey:@"transition"] isEqualToString:@"idle"])  {

    }
    else {

    }
}
//    if ([elementName isEqualToString:@"state"]) {
////        stateID = [attributeDict objectForKey:@"id"];
////        stateInfo = [[StateInfo alloc]initWithStateName:stateID];
////        NSLog(@"stateID = %@",stateID);
//        return;
//    }
if([elementName isEqualToString:@"transition"]){
    //aList=[[List alloc]init];
    stateID = [attributeDict objectForKey:@"target"];
    targetStateInfo = [[StateInfo alloc]initWithStateName:stateID];
    [stateInfo registerNextState:targetStateInfo withCondition:[attributeDict objectForKey:@"cond" ]];
    return;
}
if ([elementName isEqualToString:@"scxml"])

    {
    stateID = [attributeDict objectForKey:@"initital"];
    stateInfo = [[StateInfo alloc]initWithStateName:stateID];
    return;

  }
if ([elementName isEqualToString: @"state"] ){

    if ([[attributeDict objectForKey:@"Name"] isEqualToString:@"Child2"])  {
        // searchDone=YES;
    }
    else {
        // searchDone=NO;

    }
}
//    if ([elementName isEqualToString:@"state"]) {
////        stateID = [attributeDict objectForKey:@"id"];
////        stateInfo = [[StateInfo alloc]initWithStateName:stateID];
////        NSLog(@"stateID = %@",stateID);
//        return;
//    }
if([elementName isEqualToString:@"transition"]){
    //aList=[[List alloc]init];
    stateID = [attributeDict objectForKey:@"target"];
    targetStateInfo = [[StateInfo alloc]initWithStateName:stateID];
    [stateInfo registerNextState:targetStateInfo withCondition:[attributeDict objectForKey:@"cond" ]];
    return;
  }

}

-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{

if(!currentElementValue){
    currentElementValue=[[NSMutableString alloc]init];
}
[currentElementValue appendString:string];
//currentElementValue = (NSMutableString *) [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
 /* if(!currentElementValue)
 currentElementValue = [[NSMutableString alloc] init];
 else
 [currentElementValue appendString:string];
 */

/* if(self.currentElementValue)
{
[self.currentElementValue appendString:string];
}
*/
}

-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{
if ([elementName isEqualToString:@"scxml"])
    return;
if([elementName isEqualToString:@"state"]){
    //[aList setTitle:currentElementValue];
    //NSLog(@"alist.title = %@",aList.title);
}
    currentElementValue = nil;
 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T14:59:32+00:00Added an answer on June 12, 2026 at 2:59 pm

    This code you have commented seems to be fine:

    if ([elementName isEqualToString:@"state"]) {
            stateID = [attributeDict objectForKey:@"id"];
            stateInfo = [[StateInfo alloc]initWithStateName:stateID];
            NSLog(@"stateID = %@",stateID);
    }
    

    stateID will show idle the first time and dragging the second time.

    The xml is read from the top to the bottom

    for <state> or similar tags you have to use if ([elementName isEqualToString:@"state"])

    for attributes inside the tags like target=””, event=”” or id=”” you have to use [attributeDict objectForKey:@"target"];

    You don’t have to do anything special, when the parser finish the first </state> it will continue with the next <state>.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to parse that document with SAX: <scxml version=1.0 initialstate=start name=calc> <datamodel> <data
how can i parse element like this example <?php $xmlstr = <<<XML <?xml version='1.0'
This is my ajax code, For example URL 1 : www.text1.com and URL 2
I registered a custom editor with eclipse extension point org.eclipse.ui.editors as follows. <extension point=org.eclipse.ui.editors>
I have got below code in c#. SqlConnection conn = new SqlConnection(Data Source=MANOJ-PC\\SQLEXPRESS;Initial Catalog=master;Integrated
Is there a tool similar to Eclipse Based Visual SCXML Editor for constructing Harel
Having XML schema with the namespace http://mynamespace . If the wrong XML document with
I'm new to SCXML and I cannot start even the simplest application. When I
I have the following XML code: <para> <![CDATA[ <?php $data = '<?xml version=1.0?> <root>content</root>';
I need to build a dialog system similar to IVR used in call centers.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.