Generate UI by parsing xml using NSXMLParser

Discussion in 'iOS Programming' started by Knight Rider, May 24, 2009.

  1. Knight Rider macrumors newbie

    Joined:
    May 14, 2009
    #1
    Hi,
    I can parse the XML file using NSXMLParser. I can get the tags and the attributes....
    But my XML has tags like <Textfield>,<Label>,<Picker>..
    I have to bring these controls dynamically on view...

    And I have to display different view after getting a <Page> tag..
    How to display a different view?

    Is there any Tutorial for this..?

    Thanx in advance
     
  2. Knight Rider thread starter macrumors newbie

    Joined:
    May 14, 2009
    #2
    Generate different views using xml parsing

    Hi, In the following XML, I can display controls (textfield,buttons,labels) dynamically on view according to XML tags... I am using NSXMLParser..

    The XML is like this.....

    < page template="Login" pageIndex="1" pagetype ="Start"> < title>Sub Header < subtitle>Sub Header

    < content rowcount ="2">

    < row index="1">
    < Ctl type="Label" name="lblLogin">
    < loc pos="Left">
    < /loc>
    < text>User Name</text>
    < /Ctl>

    < Ctl type="TextBox" name ="txtLogin">
    < loc pos="Right">
    < /loc>
    <Text></Text>
    < /Ctl>
    < /row>



    < row index="2">
    < Ctl type="Label" name="lblPassword">
    < loc pos="Left">
    </loc>
    < text>Password< /text>
    < /Ctl>

    < Ctl type="TextBox" name ="txtPassword">
    < loc pos="Right">
    < /loc>
    < Text></Text>
    < /Ctl>

    < /row>
    < /content>

    ////// Two butttons : LOGIN and EXIT for login < menu> < menuItem text="Login" url="http://xxxxxxxx" Operation="LOGIN">
    < /menuItem> < menuItem text="Exit" Operation ="APP_EXIT"/>
    < /menu>

    < Opeartion id="LOGIN">
    < OnSucess goToPage="2" Message=""/>
    < OnFailure goToPage ="1" Message="Autehtication Faliure! The enterd user
    name or password is not correct."/>
    < /Opeartion>

    < Opeartion id="APP_EXIT">
    < Action>Logout< /Action>
    < /Opeartion>
    < /page>

    //////// New Page for FAQ /////// First 4 questions on page 2

    < page template="FAQ" pageIndex="2"> < title > Header < /title> < subtitle>Sub Header < /subtitle>

    < content rowcount ="4">
    < row index ="1"> < Ctl type="Label" id="FAQ2_Q1" name="lblQuestion1"> < /loc>
    < text> 1.Location of program< /text>
    < /Ctl>
    < /row>

    < row index ="2">
    < Ctl type="Label" id="FAQ2_A1" name="lblAwnser1">
    <loc></loc>
    < text>India< /text>
    </Ctl>
    </row>

    <row index ="3">
    < Ctl type="Label" id="FAQ2_Q3" name="lblQuestion3">
    <loc></loc>
    < text>2. What is the selection process< /text>
    </Ctl>
    </row>

    < row index ="4">
    < Ctl type="Label" id="FAQ2_A2" name="lblAwnser2">
    <loc></loc>
    < text>Aptitude Test</text>
    < /Ctl>
    </row>
    </content>
    ////// Button to go to next page(page no.3) and LogOff

    < menu>
    < menuItem text="Next" Operation="Next"/>
    < menuItem text="Log Off" Operation ="APP_EXIT"/>
    < /menu>
    < Operation id="Next">
    < Action goToPage="3"></Action>
    < /Operation>
    < Operation id="APP_EXIT">
    < Action>Logout</Action>
    < /Operation>
    < /page>

    I can display Username,Password labels by creating them dynamically using self.view

    But After Authentication To display FAQ page,I need to load another view (Or clear current view...) How to generate Labels on next view ? As I cant use self.view

    Any suggestions...newbie here.. Thanx in advance..
     
  3. fire.tiger macrumors newbie

    Joined:
    May 22, 2009
    #3
    You just have to make a good program logic. Where exactly you have a problem? What can't you do when you already parse the XML file?
     
  4. Knight Rider thread starter macrumors newbie

    Joined:
    May 14, 2009
    #4
    Generate different views using xml parsing

    Thanks for reply...

    I can display labels and textbox on first page..
    I am creating label as soon as I get <label> tag...Using self.view...
    [I am not parsing the XML in different class].

    So, when next <page> tag comes, if I load another view then how to Create and displaY LABEL...
    I cant use self.view...

    It may be using controllers and data passing between Views..
    But I dont know how to do it...

    Plz Help.
     
  5. objcninja macrumors newbie

    Joined:
    Mar 16, 2011
    Location:
    NY
    #5
    Generate different views using xml parsing

    Hi,

    I am trying to d something similar. I want to generate Form by parsing the xml, along with applying validations listed in XML. Is there any tutorial available online which can be helpful ?
     

Share This Page