I have an XML file which has records as below: <Users> <User&

I have an XML file which has records as below:
<Users>
<User>
<LoginId>1</Loginid>
<Company>companyname1</Company>
....
</User>
<User>
<LoginId>2</Loginid>
<Company>companyname2</Company>
....
</User>
...


</Users>

I want this XML to be ADD/EDIT/DELETE the any of USER record through Appian form.
It would be something like, input user form data should populate inside this XML.. allow to edit existing user or remove any user.
How it could be achieve

Thanks...

OriginalPostID-86629

OriginalPostID-86629

  Discussion posts and replies are publicly visible

  • Hi, You can use xpathdocument() function to get the xml information into process. You can show the data to user in the form and can give the options to add, edit or delete the data. Then use toxml() function to generate the xml format of the values in the process. Then use Text from template smart service to generate the XML file.
    Hope this helps.
  • To achive this, i need to first show list of users exists in xml file into some grid or list layour .. how to do that and Then after on click on any row/user.. i may use - xpathdocument() to fetch particular user ...

    How to achieve this..
  • For time being, i have added interface to search the user by "loginID" and using "xpathdocument()" able to fetch related fields and populate into the user's input form.

    problem: How can i update the fields back to existing XML file.. ? Please share details approach to resolve this.

    Thank You
  • You may use the "Text Doc from Template" smart service by maintaining the 'xml user Info template'.Once you read the data in UI and based on the new data structure you may populate the xml template and create an updated xml user info file.
  • In "Text doc from Template" template, need to specify parameters which can be replace with new value. In this users XML, it is not fixed on number of user nodes so... it could not be possible to pre-define the user info parameter.

    I suppose, i need like - (some string/XML function or file function which can allow to replace value for given element node so, old value replace by new value in xml file)
    OR , (fetch the whole XML >> then using some function, i could replace the particular user into XML >> then write the updated whole XML (existing in Process variable) back to XML file.

    I don't know which functions could allow me..

    please share your comments to achieve this.

    Thank You
  • You can have a single key in template to generate all the XML tags.if you want to replace old value in the document, update that value on Process Variable, where you are having the data and then generate the XML document again.
  • Can you share me...
    I have below XML:
    <Users>
    <User>
    <LoginId>1</Loginid>
    <Company>companyname1</Company>
    <web>companyname1</web>
    <phone>121212</phone>
    </User>
    <User>
    <LoginId>2</Loginid>
    <Company>companyname2</Company>
    <web>companyname2</web>
    <phone>121212</phone>
    </User>
    <User>
    <LoginId>3</Loginid>
    <Company>companyname1</Company>
    <web>companyname1</web>
    <phone>121212</phone>
    </User>
    </Users>

    I have above xml into process variables.
    Now, i suppose to fetch below user XML:
    <User>
    <LoginId>3</Loginid>
    <Company>companyname1</Company>
    <web>companyname1</web>
    <phone>121212</phone>
    </User>

    nOW,i got updated this user details from user input and found below xml node:
    <User>
    <LoginId>3</Loginid>
    <Company>final1</Company>
    <web>companyname1</web>
    <phone>121212</phone>
    </User>

    Can you please share me how to replace particular OLD block (number of lines) with new block into XML (PV). ?

    Please also let me know , how to add new user node append to last user of XML. ?
    Thank You
  • We need to generate the xml user file everytime we want to update any data.

    Please create a CDT name "userDetails" which should have the below fields
    >loginId
    >company
    >web
    >phone

    Now in your user management process use this cdt type to store all the xml user information.
    and runtime you create a rule something like this

    ruleUserInfo=concat("<User>"&"br/"<LoginId>"&userdetails.loginId&"</Loginid>"&"br/"&"</User>")

    usning MNI script task or looping function run the above rule for each user.

    Finally use joinarray("userCDT","");
    This result will be your final user info.
    pass this as argument in the "Text Doc from Template"

    To add/edit/delete the same steps needs to be follwed.
  • thanks for sharing details.

    Ok, understand CDT will store the details of one user.

    Still an query here as below:
    I suppose to follow below steps:
    1. Search user by login ID
    2. above step will use - xpathdocument(..) and store the one user xml node into process variables.
    3. using XPATH, user input form gets populate with related details as below:
    login ID - " "
    company:data
    web:data
    phone: data

    and result will store into CDT.

    4. In Script task OR output variable, i can append the details into XML format - (one user updated xml node).

    5. PROBLEM: How can i merge this particular updated one user's XML node into process vriable which hold whole XML (about to replace older with newer) ?

    Some how, i have to iterate and take each user node into the CDT and use array of CDT and follow to replace ?? if that is the case then.. i have to look for how to iterate/parase XML and fetch the each user nodes to prepare CDT...

    or please share your comments.

    Thank You.