Find and Replace for XML
I have requirements for searching through XML files and performing a number of different Find and Replace functions. They include Find and Replace:
- on content in any element
- on content within a specified element
- on attribute values within a specified element
- on attribute names within a specified element
- on element type names themselves
The last 2 Find and Replace types could invalidate the document. I'm thinking DOM would be most appropriate for this. Which java packages/classes/technologies are the best to use? BTW, I've got some experience with java and a little less with XML.
Thanks....
Hi, here is what I suggest: You can use DOM or JDOM as your tecnology. I prefer to use DOM because is the one I'm familiar with.
For the first three assignments, you can use DOM methods to get node text, data, etc.(look for the API/examples in the web). For the 2 last assignments, you may need to use XSLT to produce the OUT put XML and in some cases use filtering and concatenation. See http://java.sun.com/webservices/docs/1.0/tutorial/index.html.
Good luck!
Similar Messages
-
"Find and Replace" for field names in a fillable PDF
Is it possible to do a "Find and Replace" for the field names in a fillable PDF? For example, I have multiple fields that contain the word "Proposed Insured" as part of the field name and would like to find and replace all of them with "Owner". Is there an easy way to do this?
Not really. Even a script can't just rename a field. It needs to create a
new field on top of the old one, but then you lose all the associated
settings, like validation, calculation, format, keystroke, etc. -
How do I create a multiple find and replace for Excel in AppleScript?
I have a large dataset in Excel that I have to do a multiple find/replace in (changing USPS state abbreviations to their full names). In searching the Microsoft boards--I was directed to use Applescript, and even the documented help with Excel was recommeding this. Unfortunately, there wasn't much help potinting me in the specific direction I needed. Any ideas on how I should write this script?
Thanks!I'm confused as to why Applescript (or any script would be helpful).
You'd have to type the abbreviation and the full name into the script, the same as just using Find and Replace All. You wouldn't gain anything by using a script. Is there more to this task than you've let on?
MacTech has an article on converting from VBA to Applescript, but I'm not sure if it would have any ideas on your specific problem: http://www.mactech.com/vba-transition-guide/index-toc.html -
How to use Find and Replace for CR or TAB
How can I use PAGES 'Find and Replace' function to eliminate unwanted carriage returns or Tabs?
I tried to copy the backwards P and paste into Pages find window, but that doesn't work.
eMac Mac OS X (10.4.4) 1 G RAMCopying & pasting should work, but it isn't necessary. In the Find & Replace fields hold down the Option key & hit the return or tab key.
Peggy -
Find and replace for multiple thin space with enter...
Hi,
Im new to the InDesign Scripting. I need to replace multiple thin space with enter to single enter. Dont know how to do. Pls someone help me.
Thanks in advance,
SudhaHi Sudha,
Use the Sample code,
app.findTextPreferences = null;
app.changeTextPreferences = null;
app.findChangeTextOptions.wholeWord = false;
app.findChangeTextOptions.caseSensitive = true;
app.findChangeTextOptions.includeMasterPages = false;
app.findTextPreferences.findWhat = "<2009>^p";
app.documents.item(0).findText();
app.changeTextPreferences.changeTo = "^p";
app.documents.item(0).changeText();
app.findTextPreferences = null;
app.changeTextPreferences = null;
Regards,
Nagaraj -
Find and replace characters in file names
I need to transfer much of my user folder (home) to a non-mac computer. My problem is that I have become too used to the generous file name allowances on the Mac. Many of my files have characters such as "*" "!" "?" and "|". I know these are problems because they are often wild cards (except the pipe). Is there a way that I can do a find and replace for these characters?
For example, search for all files with an "*" and replace the "*" in the file name with an "@" or a letter? I don't mind having to use the terminal for this (I suspect it will be easier).
Is this possible? Does anyone have any suggestions?
Thank you in advance for any help you may be able to provide.
Mac OS X (10.4.8)Yep.
"A Better Finder Rename" is great for batch file renaming.
http://www.versiontracker.com/dyn/moreinfo/macosx/11366
Renamer4mac may be all you need.
Best check out VersionTracker. In fact everybody should have this site bookmarked and visited daily.
http://www.versiontracker.com/macosx/ -
Using + and - keys to change dates and times; Find and Replace event
Hi all, \
I have two iCal related questions. One has been bugging me since the Snow Leopard upgrade and the other I'm just wondering about.
1. Is it just me or is it no longer possible to use the + and - keys to increment dates and times when editing an event? It seems that now I have to actually type in the numerals instead. Is there something in the preferences I'm missing or is that just the way it is now? Seems like a step backward, if so.
2. Is there a way to do a "find and replace" for an event that occurs sporadically throughout the year, but isn't a repeating event per se? I just want to rename the event itself.Don,
...is it no longer possible to use the + and - keys to increment dates and times when editing an event?
I did not know that was possible. Try using the ↑/↓ arrow keys to increment numbers, and →/← arrow keys to change fields.
Is there a way to do a "find and replace" for an event that occurs sporadically throughout the year, but isn't a repeating event per se?
AFAIK, you have to use the search field to find the individual events, and change them when you click on the events in the search results field.
;~) -
Find and Replace feature (DW8)
I have 300+ pages, where every page includes an image, while
the image could
be the same in more than one pages.
How can I find which images are common in which pages?
Please note, that I wouldn't like to use Find and Replace for
each one of
the images, as there are more than 200 of them. I would like
a more
"general" expression instead. Something like "Find all the
pages where *any*
image file name is in more than one of them". Then, I
(probably) get a list
like the one below:
image1.jpg is included in files 10.htm, 15.htm, 20.htm
image2.jpg is included in files 30.htm, 40.htm
image3.jpg is included in files 100.htm, 150.htm, 200.htm,
300.htm
... and so on
Is there a workaround? A regular expression... an
extension...?
TIA
Please, remove hyphens to contact me"Michael Hager" <[email protected]> wrote in message
news:f3pg21$22q$[email protected]..
> Use search and replace to just find .jpg in the code for
entire local
> site.
> Then in the results pane click the save icon at the left
to save the
> results to a file.
>
> It will list every .jpg file in the site, list which
page it is in and
> show the line of text it appears in.
>
> Repeat the process for .gif, .png or any other file
types you may have on
> your site.
>
> With a little creative sorting in excel you can find all
duplicate files
> as well.
>
Creative sortings need productive minds. Don't they? ;-)
Thanks a lot! -
XML tag markers moved: Find and Replace causing problem in xml elements
Hi All,
I am doing find and replace using GREP. While using the expression like $1, $2 (Found Items) in the change to field it changes the placement of tag marker. If the found item is a part of two of more xml elements, I am getting a serious problem while replacing it. (ie. The xml tag markers are moved.)
See the screen shot below, then you may get better idea. And help me to overcome this issue.
This is just an example to show you what i'm trying to say, there are so many cases like this.
Original text/ Before doing find replace
After replacing
Green4everHi Peter and John,
but it seems to me that the example is looking for any space that
follows a semi-colon and has two word characters following it, and
repalce that with an em space. I think you could do the same using look
behind and look ahead and not need to replace the found text.
Yes you are right about the look behind and look ahead. I'd like to show some more examples to show what the actual problem is,
Original/Before Replacing,
(Consider there is another case here, instead of em-space some times normal word space will also be there)
Using the Grep:
Find What---------> ^(\d+\.(?:\d+)?)~m
Change To------------->$1\t
After Replace:
Did I make any sense? Eventhough this will not make any changes in the layout, my requirement is to insert the tab out-side the tag marker not indise.
Green4ever -
How can i find and replace xml tags?
Hi, i am using xml in my workflow and want to be able to remove certain tags if they contain particular text.
here is an example of my xml structure…
<entry>
<name>DEFAULT</name>
<tel>DEFAULT</tel>
<address>DEFAULT</address>
</entry>
I am using this initial structure to set the paragraph styles to be followed when the xml data is imported.
This leaves DEFAULT in place wherever an entry doesn't have any content for that field.
I want to be able to import my XML then run a script that removes any tags that include DEFAULT, - I need the entire xml tag to be removed not just the text, if i do a normal find and replace it will only remove the text not the tags which is causing problems with styling. I also want to remove the end of para/return (^p) that i've placed at the end of the line. So it would be the same as opening up story editor and removing the content + tags + hard return in there, but i want to automate the process…
So i think this is what i need to search for in each case
"<name>DEFAULT</name>^p"
and i want to replace it with nothing ""
Can this be done through scripting (ideally javascript)?
I have a little knowledge of javascript but am not sure how to search and target that kind of string in indesign...
using indesign cs5
many thanksHi,
Script should do it in two steps:
1. find all occurences of i.e. ">DEFAULT<"
2. remove whole paragraph which is a found_text's container.
For example this way -JS - (a textFrame filled with your text should be selected) :
var mStory = app.selection[0].parentStory;
app.findTextPreferences = null;
app.findTextPreferences.findWhat = ">DEFAULT<";
var myF = mStory.findText();
var count = myF.length;
while (count--)
myF[count].paragraphs[0].remove();
rgds -
Using applescript for Find and Replace All in Pages 2.0
i saw that Pages 2.0 is scriptable
i try to create a script for merge use to find and replace all occurence of a certain string using a script but Pages doesn't seems to respond to "Find" even using "System Events"
how can i do to use this function with a script
Thanx for any help
S.B.
ibook G3 Mac OS X (10.4.6)OK, here's another example. This one gets the text as a string and uses the offset property to find "[", presuming it to be a merge delimiter. (Pages' text doesn't support "offset of").
One failing of this scheme is that the offsets are incorrect if you have inline objects (pictures, shapes, tables, etc.). While it is probably possible to compensate for them, that's a trickier proposition.
<PRE>-- Example merge replacements:
property mergeText : {"[name]", "John Smith", "[address]", "1234 Anystreet"}
on lookup(mergeWord)
set theCount to count of mergeText
repeat with x from 1 to theCount by 2
if item x of mergeText = mergeWord then
return item (x + 1) of mergeText
end if
end repeat
-- If merge field is not found, delete it (replace it with the empty string)
return ""
end lookup
tell application "Pages"
repeat
tell body text of document 1
-- Get text as a string so that "offset of" can be used.
set allText to it as string
set startOffset to offset of "[" in allText
if (startOffset = 0) then
exit repeat
end if
set endOffset to offset of "]" in allText
select (text from character startOffset to character endOffset)
end tell
set mergeWord to contents of selection
tell me to lookup(mergeWord)
set replacement to result
set selection to replacement
if (replacement is "") then
-- Get rid of extra whitespace (space or return)
-- Do it in a "try" block to handle edge cases at start or end of text.
try
set theSel to (get selection)
set ch1 to character before theSel
set ch2 to character after theSel
if ((ch1 is " " or ch1 is return) and (ch2 is " " or ch2 is return)) then
select character after theSel
delete selection
end if
end try
end if
end repeat
end tell</PRE>
Titanium PowerBook Mac OS X (10.4.6) -
How to find and replacing the path (url) given for data binding from type 'datasocket'
Hi everyone,
I'm sorry to pose this question as my own knowledge is still very limited.
I have an assignment (bachelor level). We were asked to adjust a plc program in step7 so that multiple of an existing sequence could be run indepently.
The settings for that sequence are controlled by labview. Sensor data is also viewed in labview.
There is an existing labview VI that was made by someone else before us. It uses 'Datasocket' type for data binding. Because we would like to adjust this VI to be used with the other sequences, we would like to change the original path or URL quickly, as in a 'Find&Replace' solution. Yet the find and replace only works for objects or text, not entries in the properties.
Can someone please tell me if there is a way to do is, without having to use shared variables, as we are not at all known with this type.
Many thanks,
NielsDear Niels,
Please find the attached example. I placed 5 controls on the front panel, all with a data socket URL (control 1 = URL1, control 2 = URL2 etc). Through property nodes I did the following;
- I got a reference to the front panel
- with this reference we can get an array of references to the controls on this front panel
- one by one we will read the references and check the data socket URL from the control, we compare this with the URL we are searching
- if found, stop we will use the reference to write a new URL to the control.
Please notice the default values of the controls; it is set to search for URL3 and replace this with URL10, run the VI once and you will see that happening. I also included a sting indicator which will show you the label of the control which we find. Also a Boolean indicator in case we were not able to find the URL.
I downsaved the VI to 8.6, I'm not sure in which version you are working, if you have 8.6 or higher you are able to open it. Hope this brings you further,
Best regards,
Martijn S
Applications Engineer
NI Netherlands
Attachments:
findURLexample.vi 12 KB -
Find and Replace Issue Help Requested.
Hi all. I've been digging around for a couple of days and
can't seem to figure this one out. For starters, I have already
looked at the Regular Expression syntax and tried the MS word
clean-up option, but no luck. We have about 1,500 pages of content.
They are in DNN, so the pages are created dynamically.
Unfortunately, the page content was written in Word and then dumped
in DNN. We are trying to clean up the pages. We are grabbing the
content from Dot Net Nuke and putting it into Dreamweaver 8.0.2.
Then we are manually cleaning out things like:
<?xml:namespace prefix = o ns =
"urn:schemas-microsoft-com:office:office" />
and
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"
align=left>
We are using the Find and Replace funtion in Dreamweaver to
clean out these commands, but I know from the documentation, there
is an easier way to clean these pages.
Bottom Line: Since the pages are dynamically built, I know I
have to grab the page content and put it in Dreamweaver manually
and then put it back in DNN, but I am trying to find a way (using
Regular Expressions or something) to look for all the little
variances of MSO, <?XML, etc. in a straight shot. I would like
to find a way to use a wild card to look for all tags that have MSO
or Microsoft or ?XML in them and then replace them with a null
value. From what I can tell, the Find would have to use a wildcard
because the advanced find features don't carry what I am looking
for. Something like Find \<?xml * [<-wildcard] to \> to
grab the entire tag. The Find tag command doesn't work because the
tags I need aren't listed. Also, because the content is dynamic, I
can't do a Fins and Replace against the entire site for these
commands, but it would be nice to "Find" all of these items with a
single pass since the "Replace" value is always null.
The wildcard syntax and multiple Find instances are the main
questions. The wildcards seem to be character or space specific.
Sorry for the long explanation - I just don't want to waste
anyone's time typing responses to things I've already tried to do.
Thanks in advance for any help. This is my first time back in
the forums in about 4 years.sadamec1 wrote:
> Well David, you Findmaster - it worked! (At least it
found and highlighted the
> code). Now, I need to dig through what you sent me and
compare it against my
> regular expression definitions to find out how to grab
the rest of these
> phrases. You're the best. Thank you!
Glad that it did the trick. Just to help you understand what
I did,
there are two main sections, as follows:
<\?xml[^>]+>
and
<[^>]+(?=class=Mso)[^>]+>
They are separated by a vertical pipe (|), so they simply act
as
alternatives.
The first one searches for <?xml followed by anything
except a closing
bracket until it reaches the first closing bracket.
The second one is more complex. It begins with this:
<[^>]+
This simply looks for an opening bracket followed by anything
other than
a closing bracket. What makes it more intelligent is the next
bit:
(?=class=Mso)
This does a forward search for "class=Mso". It's then
followed by this
again:
[^>]+>
That finds anything except a closing bracket followed by a
closing bracket.
The bit that you need to experiment with is (?=...). It's
technically
called a "forward lookaround". The effect is that the second
half of the
regex finds <....class=Mso....>.
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/ -
How to find and replace text in Excel with Automator
I am new to Automator. And I would like some help how I can create a service that will allow me to find and replace certain text in Excel. I noticed that there is an action to do this for Word documents, but not for Excel document.
Any suggestions how I can do this?
Thanks so much for your help.Easiest way to do it is the following:
- Open the PDF file in Acrobat.
- Go to Tools - Forms - More Form Options - Export Data.
- Save the form data as an XML file somewhere on your system.
- Open XML the file in a plain-text editor (I recommend Notepad++).
- Let's say you want to replace all the years in the dates from "2013" to "2014". Do a global Search&Replace of "2013-" to "2014-" (I added the dash just to make sure that only date fields are edited).
- Save the XML file (maybe under a new name).
- Go back to the PDF file, and now go to Tools - Forms - More Form Options - Import Data.
- Select the edited XML file and import it.
- Done! -
how to find and replace data in form fields in acrobat xi, its not allowing to do so while trying, asking for adobe livecycle to get installed. please help.
Easiest way to do it is the following:
- Open the PDF file in Acrobat.
- Go to Tools - Forms - More Form Options - Export Data.
- Save the form data as an XML file somewhere on your system.
- Open XML the file in a plain-text editor (I recommend Notepad++).
- Let's say you want to replace all the years in the dates from "2013" to "2014". Do a global Search&Replace of "2013-" to "2014-" (I added the dash just to make sure that only date fields are edited).
- Save the XML file (maybe under a new name).
- Go back to the PDF file, and now go to Tools - Forms - More Form Options - Import Data.
- Select the edited XML file and import it.
- Done!
Maybe you are looking for
-
when i got the new computer i had to downlaod a new itunes library. on my backup hard drive is the old itunes library but it wont let me open it . how can i get my old music on the new itunes??
-
Hi, I have to implement the following scenario in SSIS but don't know how to do since I never worked with SSIS before. Please help me. I have 20 different text files in a single folder and 20 different tables corresponding to each
-
Seems simple right? Hook up to a computer and restore and bypass disable screen? NOPE. Everytime I tried to connect it to iTunes it gives me a lovely message that says something to the effect of " cannot sync to itunes because passcode needs to be e
-
BUG: Channel-based blend modes in FW CS5 & CS6
I've observed problems with some of the blend modes in Fireworks CS5 and CS6. Several are definitely broken—most likely a by-product of changes introduced in CS5, which attempted to match some of Photoshop's blend mode behaviors (for Hue, Saturation,
-
1z0-030 oracle 8i to 9i upgrade
If any one have the required material to pass - 1z0-030 oracle 8i to 9i upgrade, Please send it to the mail id [email protected] It will be greatefull to one and all in helping me - in advance Naveen