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 7604053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:48:38+00:00 2026-05-30T23:48:38+00:00

Given a sample xml file: <root> <tag attr=value>Content</tag> <tag attr=value2>Content</tag> </root> how do i

  • 0

Given a sample xml file:

<root>
  <tag attr="value">Content</tag>
  <tag attr="value2">Content</tag>
</root>

how do i replace every tag with a different tag so i get a different file:

<root>
  <tag2 attr2="value"/>
  <tag2 attr2="value2"/>
</root>

The documentation [1] seems to use Filters, is there a way to accomplish this with arrows alone?


Update

i am now at the point where i can replace a node like this:

runX $ readDocument [] "in.xml" 
       >>> processTopDown( 
               (eelem "tag2" += sattr "attr2" "XXX" ) 
               `when` (isElem >>> hasName "tag") ) 
       >>> writeDocument [] "test.xml"

but i have no idea on how to get the attribute right.


[1] http://www.haskell.org/haskellwiki/HXT#Transform_external_references_into_absolute_reference

  • 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-05-30T23:48:40+00:00Added an answer on May 30, 2026 at 11:48 pm

    Try setElemName, processAttrl, and changeAttrName from Text.XML.HXT.XmlArrow:

    runX $ readDocument [] "in.xml" >>> transform >>> writeDocument [] "test.xml"
      where
        transform = processTopDown $
          ( setElemName (mkName "tag2") >>>
            processAttrl (changeAttrName $ mkName . attrMap . localPart)
          ) `when` (isElem >>> hasName "tag")
        attrMap "attr" = "attr2"
        attrMap a = a
    

    This works for me with your sample document.

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

Sidebar

Related Questions

I've been given a sample XML file (ultimately my client will receive several of
Given some sample data.xml file: <?xml version=1.0 encoding=utf-8?> <data> <categories> <category id=google> <name>Google</name> </category>
I have 5 different key/value pairs and I know how my xml file should
The podcast howto on the Apple website shows a sample XML file, which refers
Given the following XML file: <?xml version=1.0 encoding=UTF-8?> <process name=TestSVG2 xmlns=http://www.example.org targetNamespace=http://www.example.org xmlns:xsd=http://www.w3.org/2001/XMLSchema> <sequence>
Given this XML: <?php $xml = <<<XML <?xml version=1.0 encoding=UTF-8 ?> <root> <project type=residential>
A test sample of my xml file is shown below: test.xml <feed> <entry> <title>Link
Ihave an xml file sample.xml i need to display number from above xml file
Ihave an xml file sample.xml <?xml version=1.0 standalone=yes?> <DataSchema xmlns=http://tempuri.org/DataSchema.xsd> <ManagedObject> <Label>sam</Label> <Owner>00000000-0000-0000-0000-000000000000</Owner> <ClassID>00000000-0000-0000-0000-000000000008</ClassID>
Following is sample XML File - <?xml version=1.0 encoding=UTF-8?> <Catalog> <Book> <AName>Steven Holzner</AName> <BName>Using

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.