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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:54:57+00:00 2026-06-02T07:54:57+00:00

I need to edit some XML files, and would like to create a script

  • 0

I need to edit some XML files, and would like to create a script to do this. My experience with XML is almost non-existent, which is why I’m asking your help.

The XML below contains 2 transport orders: one that has a positive value element, and one that has a negative value. What I would like to do is, for every transport order that contains negative value:

  • replace the pickup_task‘s addressid with the delivery task‘s addressid, and vice versa
  • replace the pickup task’s taskwindow (from_instant and till_instant) with the values of the delivery task.

Is it possible to make a VB script or batch or something that could replace these for a file with more than 200 transport_orders?

Thanks

<?xml version="1.0" encoding="iso-8859-2"?>
<misu version="2010">
    <transport_orders>
        <transport_order>
            <id>NOCCO/12-006798_1</id>
            <order_number>NOCCO/12-006798_1</order_number>
            <order_date>2012-03-30</order_date>
            <contactId>C04396</contactId>
            <productId>0103-01101025</productId>
            <sum>3135.51</sum>
            <currency_code></currency_code>
            <reference>NOCCO/12-006798</reference>
            <amounts>
                <amount>
                    <unit_code>kg</unit_code>
                    <value>324.00</value>
                </amount>
            </amounts>
            <pickup_task>
                <addressid>BUCU</addressid>
                <task_window>
                    <from_instant>2012-04-20T18:26:43</from_instant>
                    <till_instant>2012-04-20T18:26:43</till_instant>
                </task_window>
            </pickup_task>
            <delivery_task>
                <addressid>C04396_1</addressid>
                <task_window>
                    <from_instant>2012-04-23T00:00:00</from_instant>
                    <till_instant>2012-04-24T00:00:00</till_instant>
                </task_window>
            </delivery_task>
        </transport_order>
        <transport_order>
            <id>NOCCO/12-007016_2</id>
            <order_number>NOCCO/12-007016_2</order_number>
            <order_date>2012-04-02</order_date>
            <contactId>C01137</contactId>
            <productId>0604-08L15000</productId>
            <sum>495.00</sum>
            <currency_code></currency_code>
            <reference>NOCCO/12-007016</reference>
            <amounts>
                <amount>
                    <unit_code>m2</unit_code>
                    <value>-5.00</value>
                </amount>
            </amounts>
            <pickup_task>
                <addressid>SFGH</addressid>
                <task_window>
                    <from_instant>2012-04-20T18:26:43</from_instant>
                    <till_instant>2012-04-20T18:26:43</till_instant>
                </task_window>
            </pickup_task>
            <delivery_task>
                <addressid>C01137_1</addressid>
                <task_window>
                    <from_instant>2012-04-23T00:00:00</from_instant>
                    <till_instant>2012-04-24T00:00:00</till_instant>
                </task_window>
            </delivery_task>
        </transport_order>
    </transport_orders>
</misu>
  • 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-02T07:54:58+00:00Added an answer on June 2, 2026 at 7:54 am

    Here ya go … this should accomplish part 1. I’ll leave part 2 up to you (I’m not used to VB). As you can see I named the XML file “data.xml”.

    Sub Main()
        Dim xdoc As XDocument
        Dim filename As String
        filename = "../../data/data.xml"
        xdoc = XDocument.Load(filename)
        Dim xe As XElement
        xe = xdoc.Root.Element("transport_orders")
        For Each element In xe.Elements("transport_order")
            Dim val As Integer
            val = element.Element("amounts").Element("amount").Element("value").Value
            If (val < 0) Then
                Console.WriteLine(val)
                Dim puelement As XElement
                Dim delelement As XElement
                Dim putask As String
                puelement = element.Element("pickup_task").Element("addressid")
                delelement = element.Element("delivery_task").Element("addressid")
                putask = delelement.Value
                delelement.Value = puelement.Value
                puelement.Value = putask
            End If
        Next
        xdoc.Save(filename)
        Console.ReadLine()
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to manually edit some of the files inside of the .cmp file
I need to edit XML files on a small Linux box that we have
Well, i have this thing, i need to edit a XML file that is
We're generating MP3 files on the fly in Python, and need to edit the
I have developed some reusable android component which is basically a class . This
I'd like to store some relatively simple stuff in XML in a cascading manner.
I am quite new in vbs and I would like some of your help
I have some XML which features a fair number of attributes in each element,
I have various binary file formats which I need to dump to some kind
In my android app, I create thumbnails in xml this way: <ImageView android:id=@+id/my_thumbnail android:layout_width=50dp

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.