xml editor

Products

Features

  EPUB
Supported platforms

Supports Windows 7 & Mac OS X Lion

Ready for XML Editor data server software
W3C Member

Automatically change the 2nd part of a tag

Questions about XML that are not covered by the other forums should go here.

Automatically change the 2nd part of a tag

Postby Gale_D » Mon Feb 01, 2010 11:38 pm

I am new to XML editing, having trained myself, and I cannot figure out how to do this action:

I was using this tag: <name type="place"></name>, and I want to change it to <placeName></placeName>. I do not want to have to do this manually for 60+ large XML files.

Is there a way to make Oxygen change the 2nd part of a tag when the first part is changed using Find ->Replace?

Sorry if this is a simple question. I wasn't sure what to search for to find an answer.

thanks,
Gale_D
Gale_D
 
Posts: 2
Joined: Mon Feb 01, 2010 11:23 pm

Re: Automatically change the 2nd part of a tag

Postby adrian » Tue Feb 02, 2010 12:50 pm

Hi,

I'm assuming there is some content between the tags:
Code: Select all
<name type="place">
...(content)
</name>

If there isn't you can simply use the Find/Replace in Files and replace one string with the other.

If there is content between the tags and the name elements aren't nested (name inside another name element) you can do this in two steps with Find -> Find/Replace in Files in Oxygen 11.1(which has XPath and XML filters):

Step 1 - Replace element 'name'(with attribute type="place") -> 'placeName':
Text to find: 'name'
Case sensitive, Whole words only
Restrict to XPath: //name[@type="place"]
Enable XML search options(checked)
Search only in: Element names(checked)
Replace with: 'placeName'

Make sure the correct scope and filters are specified.
You can try first a 'Find All' to check if it does what is expected and then 'Replace All'.

Step 2 - Remove ' type="place"' from elements 'placeName':
Text to find: ' type="place"'
Case sensitive
Restrict to XPath: //placeName[@type="place"]
Enable XML search options(unchecked)
Replace with: ''(empty)

Again make sure the correct scope and filters are specified and maybe try a Find All to check the find results.

Let me know if you need further help.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
adrian
 
Posts: 854
Joined: Tue May 17, 2005 4:01 pm

Re: Automatically change the 2nd part of a tag

Postby Gale_D » Tue Feb 02, 2010 10:22 pm

Thank you for the tip...

one problem I have with the "replace element 'name' with 'placeName'" --

'name' closes several other 'xName' tags. So if I replace all of 'name' with 'placeName', I'll end up with (for example) a tag like this:

<personName>content</placeName>
Gale_D
 
Posts: 2
Joined: Mon Feb 01, 2010 11:23 pm

Re: Automatically change the 2nd part of a tag

Postby adrian » Wed Feb 03, 2010 10:21 am

Gale_D wrote:'name' closes several other 'xName' tags.
You mean you have an XML file that has tags like this <personName>content</name> ? But that's not even XML well-formed, shouldn't you correct those first?

XPath and XML search options do not work on documents that are not XML well-formed so it's going to be very difficult to do what you want.

Please correct me if I misunderstood.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
adrian
 
Posts: 854
Joined: Tue May 17, 2005 4:01 pm


Return to General XML Questions

Who is online

Users browsing this forum: No registered users and 0 guests

XML Editor | XML Author | WYSIWYG Editors | Schema Editor | XSD Documentation | XSL/XSLT Editor | XQuery | XML Databases | SVN Client
© 2002-2011 SyncRO Soft Ltd. All rights reserved. | Sitemap | Privacy Policy | This website was created & generated with <oXygen/>® XML Editor