Powershell: How do I upload files with metadata from a manifest file?

I am using the script from this blog to try to upload files into SharePoint, using a manifest file to specify the metadata associated with each file. Right now, the script works, but is not populating
the metadata from the manifest (xml) file. When I write the $metadataManifest variable out to the console, I get the contents of my xml file, so the code is reading the file when it should. However when it gets to the line in bold ($metadataManifest.Columns.Column),
it does not go into that block...it just skips on to checkin the file. Again the $metadataManifest variable shows all the content in my xml manifest file. Here is what the script looks like...
#Get web and document library objects
$web = Get-SPWeb "http://companySite"
$Library = "My Library"
$docLibrary = $web.Lists[$Library]
$ManifestFilePath = "C:\PowerShellScripts\Manifest.xml"
$LocalPath = "C:\Upload\Test Upload\My Upload Directory\"
if ($ManifestFilePath)
$metadataManifest = (Get-Content ($ManifestFilePath))
write-host "Manifest file: " $metadataManifest
else
write-host "Manifest file not specified for categorising uploaded documents"
#Check for the LibraryStartFolder parameter to specify a root folder
if ($PSBoundParameters.ContainsKey('LibraryStartFolder')) {
$folder = $web.GetFolder($docLibrary.Title + $LibraryStartFolder)
else
$folder = $docLibrary.RootFolder
#Attach to local folder and enumerate through all files
if($IncludeSubFolders) {
$files = Get-ChildItem $LocalPath -Recurse
else
$files = Get-ChildItem $LocalPath
$files | ForEach-Object {
#Check if the object is a folder - if so, create it in doc library
if ($_.PSIsContainer) {
if (($IncludeSubFolders) -and (!$FlattenStructure)) {
#Generate folder path for creation in SharePoint
#by looking at the parent folder on the local path
$spFolderPath = ($_.Parent.FullName.Replace($LocalPath,"")).Replace("\","/")
#Get the folder into which the new folder will be created
#by adding the folder path generated above, if one existed
if ($spFolderPath -eq "") {
$currentFolder = $web.GetFolder($folder.Url)
else
$currentFolder = $web.GetFolder($folder.Url + $spFolderPath)
#Check to see if subfolder already exists
#and create it if not
$testFolder = $currentFolder.SubFolders[$_.Name]
if ($testFolder -eq $null) {
write-host "`nAdding folder" $_.Name "to" $docLibrary.Title "in" $web.Title "..." -foregroundcolor Green
$newFolder = $currentFolder.SubFolders.Add($_.Name)
else
write-host "`nFolder" $_.Name "already exists in" $docLibrary.Title "and shall not be created" -foregroundcolor Red
else
#Generate file path for upload into SharePoint
if ($FlattenStructure) {
$spFilePath = ("/" + $_.Name)
else
$spFilePath = ($_.FullName.Replace($LocalPath,"")).Replace("\","/")
$spFullPath = $folder.Url + "/" + $spFilePath
#Check if the file exists and the overwrite option is selected before adding the file
if ((!$web.GetFile($spFullPath).Exists) -or ($Overwrite)) {
#Add file
write-host "`nCopying" $_.Name "to" $spFullPath.Replace("/" + $_.Name,"") "in" $web.Title "..." -foregroundcolor Green
$spFile = $folder.Files.Add($spFullPath, $_.OpenRead(), $true)
#$spFile = $folder.Files.Add($folder.Url + "/" + $file.Name, [System.IO.Stream]$fileStream, $true)
$spItem = $spFile.Item
#Walk through manifest XML file and configure column values on the file
$metadataManifest.Columns.Column | ForEach-Object {
#Single value text columns
try
if (($_.Type -eq "Text") -or
($_.Type -eq "Choice") -or
($_.Type -eq "Boolean") -or
($_.Type -eq "Number") -or
($_.Type -eq "Currency")) {
$columnName = $_.Name
write-host "Setting value on column"$columnName "..." -foregroundcolor Blue
$_.Values.Value | ForEach-Object {
$spItem[$columnName] = $_
write-host "Value set to"$_
catch {}
#Multiple line text column
try
catch {}
#Multiple choice columns
try
catch {}
#Hyperlink columns
try
catch {}
#Single User column
try
catch {}
#Multiple User column
try
catch {}
#Single value Managed Metadata column
try
catch {}
#Multi value Managed Metadata column
try
catch {}
#Update document with new column values
$spItem.SystemUpdate($false)
#Check in file to document library (if required)
#MinorCheckIn=0, MajorCheckIn=1, OverwriteCheckIn=2
if ($CheckIn) {
if ($spFile.CheckOutStatus -ne "None") {
$spFile.CheckIn("File copied from " + $filePath, 1)
write-host $spfile.Name"checked in"
#Approve file (if required)
if ($Approve) {
if ($spItem.ListItems.List.EnableModeration -eq $true) {
$spFile.Approve("File automatically approved after copying from " + $filePath)
if ($spItem["Approval Status"] -eq 0) { write-host $spfile.Name"approved" }
else
write-host "`nFile"$_.Name "already exists in" $spFullPath.Replace("/" + $_.Name,"") "and shall not be uploaded" -foregroundcolor Red
$web.Dispose()
And here is what the manifest file looks like...
<?xml version="1.0" encoding="utf-8"?>
<Columns>
<Column Name="Column1" Type="Text">
<Values>
<Value>First File</Value>
</Values>
</Column>
<Column Name="Column2" Type="Text">
<Values>
<Value>12585</Value>
</Values>
</Column>
<Column name="Column3" type="Text">
<Values>
<Value>Some Data</Value>
</Values>
</Column>
<Column name="Column4" type="Text">
<Values>
<Value>More Data</Value>
</Values>
</Column>
</Columns>
<Columns>
<Column Name="Column1" Type="Text">
<Values>
<Value>Second File</Value>
</Values>
</Column>
<Column Name="Column2" Type="Text">
<Values>
<Value>9876</Value>
</Values>
</Column>
<Column name="Column3" type="Text">
<Values>
<Value>Some Data2</Value>
</Values>
</Column>
<Column name="Column4" type="Text">
<Values>
<Value>More more Data</Value>
</Values>
</Column>
</Columns>
I can't figure out what am doing wrong...why my script is not iterating through the manifest file to upload the document along with the metadata. I would really appreciate any help. Thanks

Hi Spawn,
Name should not be a problem.. I will probably post you the entire code (I modified it to meet your goals for having multiple column xml nodes as well)
For the code snippet below:
a. In powershell all my changes will have ## prefixed comments
b. in XML I have changed one column name to "Name" to replicate your case and also added a parent node for making the xml well formed.
and the SharePoint output
Please see the code below
$web = Get-SPWeb "http://intranet/sites/test"
$Library = "My Library"
$docLibrary = $web.Lists[$Library]
$ManifestFilePath = "D:\Manifest.xml"
$LocalPath = "D:\UploadPath\"
if ($ManifestFilePath)
##read the xml file as an xml object
[xml]$metadataManifest = (Get-Content ($ManifestFilePath))
write-host "Manifest file: " $metadataManifest
else
write-host "Manifest file not specified for categorising uploaded documents"
#Check for the LibraryStartFolder parameter to specify a root folder
if ($PSBoundParameters.ContainsKey('LibraryStartFolder')) {
$folder = $web.GetFolder($docLibrary.Title + $LibraryStartFolder)
else
$folder = $docLibrary.RootFolder
#Attach to local folder and enumerate through all files
if($IncludeSubFolders) {
$files = Get-ChildItem $LocalPath -Recurse
else
$files = Get-ChildItem $LocalPath
$counter=0
$files | ForEach-Object {
#Check if the object is a folder - if so, create it in doc library
if ($_.PSIsContainer) {
if (($IncludeSubFolders) -and (!$FlattenStructure)) {
#Generate folder path for creation in SharePoint
#by looking at the parent folder on the local path
$spFolderPath = ($_.Parent.FullName.Replace($LocalPath,"")).Replace("\","/")
#Get the folder into which the new folder will be created
#by adding the folder path generated above, if one existed
if ($spFolderPath -eq "") {
$currentFolder = $web.GetFolder($folder.Url)
else
$currentFolder = $web.GetFolder($folder.Url + $spFolderPath)
#Check to see if subfolder already exists
#and create it if not
$testFolder = $currentFolder.SubFolders[$_.Name]
if ($testFolder -eq $null) {
write-host "`nAdding folder" $_.Name "to" $docLibrary.Title "in" $web.Title "..." -foregroundcolor Green
$newFolder = $currentFolder.SubFolders.Add($_.Name)
else
write-host "`nFolder" $_.Name "already exists in" $docLibrary.Title "and shall not be created" -foregroundcolor Red
else
#Generate file path for upload into SharePoint
if ($FlattenStructure) {
$spFilePath = ("/" + $_.Name)
else
$spFilePath = ($_.FullName.Replace($LocalPath,"")).Replace("\","/")
$spFullPath = $folder.Url + "/" + $spFilePath
#Check if the file exists and the overwrite option is selected before adding the file
if ((!$web.GetFile($spFullPath).Exists) -or ($Overwrite)) {
#Add file
write-host "`nCopying" $_.Name "to" $spFullPath.Replace("/" + $_.Name,"") "in" $web.Title "..." -foregroundcolor Green
$spFile = $folder.Files.Add($spFullPath, $_.OpenRead(), $true)
#$spFile = $folder.Files.Add($folder.Url + "/" + $file.Name, [System.IO.Stream]$fileStream, $true)
$spItem = $spFile.Item
## ensure we pick the corresponding node in the columns xml (first file, first xml node, second file - second node likewise)
#Walk through manifest XML file and configure column values on the file
$metadataManifest.FileData.Columns[$counter].Column | ForEach-Object {
#Single value text columns
try
if (($_.Type -eq "Text") -or
($_.Type -eq "Choice") -or
($_.Type -eq "Boolean") -or
($_.Type -eq "Number") -or
($_.Type -eq "Currency")) {
$columnName = $_.Name
write-host "Setting value on column"$columnName "..." -foregroundcolor Blue
$_.Values.Value | ForEach-Object {
$spItem[$columnName] = $_
write-host "Value set to"$_
catch {}
#Multiple line text column
try
catch {}
#Multiple choice columns
try
catch {}
#Hyperlink columns
try
catch {}
#Single User column
try
catch {}
#Multiple User column
try
catch {}
#Single value Managed Metadata column
try
catch {}
#Multi value Managed Metadata column
try
catch {}
#Update document with new column values
$spItem.SystemUpdate($false)
##increment the counter to read the next xml node
$counter++
#Check in file to document library (if required)
#MinorCheckIn=0, MajorCheckIn=1, OverwriteCheckIn=2
if ($CheckIn) {
if ($spFile.CheckOutStatus -ne "None") {
$spFile.CheckIn("File copied from " + $filePath, 1)
write-host $spfile.Name"checked in"
#Approve file (if required)
if ($Approve) {
if ($spItem.ListItems.List.EnableModeration -eq $true) {
$spFile.Approve("File automatically approved after copying from " + $filePath)
if ($spItem["Approval Status"] -eq 0) { write-host $spfile.Name"approved" }
else
write-host "`nFile"$_.Name "already exists in" $spFullPath.Replace("/" + $_.Name,"") "and shall not be uploaded" -foregroundcolor Red
$web.Dispose()
and the xml file
<?xml version="1.0" encoding="utf-8"?>
<FileData>
<Columns>
<Column Name="Name" Type="Text">
<Values>
<Value>First File</Value>
</Values>
</Column>
<Column Name="Column2" Type="Text">
<Values>
<Value>12585</Value>
</Values>
</Column>
<Column name="Column3" type="Text">
<Values>
<Value>Some Data</Value>
</Values>
</Column>
<Column name="Column4" type="Text">
<Values>
<Value>More Data</Value>
</Values>
</Column>
</Columns>
<Columns>
<Column Name="Name" Type="Text">
<Values>
<Value>Second File</Value>
</Values>
</Column>
<Column Name="Column2" Type="Text">
<Values>
<Value>12585</Value>
</Values>
</Column>
<Column name="Column3" type="Text">
<Values>
<Value>Some Data</Value>
</Values>
</Column>
<Column name="Column4" type="Text">
<Values>
<Value>More Data</Value>
</Values>
</Column>
</Columns>
<Columns>
<Column Name="Name" Type="Text">
<Values>
<Value>Third File</Value>
</Values>
</Column>
<Column Name="Column2" Type="Text">
<Values>
<Value>12585</Value>
</Values>
</Column>
<Column name="Column3" type="Text">
<Values>
<Value>Some Data</Value>
</Values>
</Column>
<Column name="Column4" type="Text">
<Values>
<Value>More Data</Value>
</Values>
</Column>
</Columns>
<Columns>
<Column Name="Name" Type="Text">
<Values>
<Value>Fourth File</Value>
</Values>
</Column>
<Column Name="Column2" Type="Text">
<Values>
<Value>12585</Value>
</Values>
</Column>
<Column name="Column3" type="Text">
<Values>
<Value>Some Data</Value>
</Values>
</Column>
<Column name="Column4" type="Text">
<Values>
<Value>More Data</Value>
</Values>
</Column>
</Columns>
<Columns>
<Column Name="Name" Type="Text">
<Values>
<Value>Fifth File</Value>
</Values>
</Column>
<Column Name="Column2" Type="Text">
<Values>
<Value>12585</Value>
</Values>
</Column>
<Column name="Column3" type="Text">
<Values>
<Value>Some Data</Value>
</Values>
</Column>
<Column name="Column4" type="Text">
<Values>
<Value>More Data</Value>
</Values>
</Column>
</Columns>
</FileData>
Thanks and Regards,
Partha
AvePoint

Similar Messages

  • How do i remove the exif metadata from my jpg file produced with a digital camera photo?

    How do i remove the exif metadata from my jpg file produced with a digital camera photo?

    The excellent and free utility Irfanview has the option to remove the EXIF data.
    Simply open and the file and do a Save, or Save As with the original name.
    Surprisingly, the default is to not keep the original EXIF data.

  • Problem in exporting library files with project(Classpath in manifest file)

    I've developed a J2EE application client using Eclipse 3.3.1.1, now I want to export my project as a executable jar file but there is a lot of external jar files so when I put their name in Class-Path variable of project's Manifest, I see "Too long" error because there are too many external jar files.
    How I can export required jar files with executable file of my project?
    In my idea, the process of application client exporting is so foolishly and silly! why there isn't any standard and easy-to-use utility for this reason?!

    Nazi wrote:
    I've developed a J2EE application client using Eclipse 3.3.1.1, now I want to export my project as a executable jar file but there is a lot of external jar files so when I put their name in Class-Path variable of project's Manifest, I see "Too long" error because there are too many external jar files.
    How I can export required jar files with executable file of my project?
    In my idea, the process of application client exporting is so foolishly and silly! why there isn't any standard and easy-to-use utility for this reason?!Probably a Jewish Bolshevik conspiracy...
    Abuse reported

  • How can I copy songs with metadata (added in iTunes) from my PC to my new iMac?

    I have iTunes 12.0.1 on my Windows PC. I'm about to get a new iMac (hooray!) and I'm beginning the process of transferring everything on my PC to my Mac. I've got all the documents, pictures, files, etc. covered, but now I have to make a copy of all of my music.
    Most of the music in my iTunes library is not bought through the iTunes Store (I download most of my songs from the Internet). Then, after saving the downloaded song to my computer, I go into iTunes on my computer and add the song. I also add metadata like artist, album, genre, album artwork, etc. to the song in iTunes. What concerns me is that only the songs in iTunes have this metadata: the original downloaded files I saved onto my computer don't have any metadata.
    I really don't want to have to go through the long and tedious process of adding artist/album names, genre, etc. to every single song in my iTunes library on my new iMac. How can I copy songs with metadata (added in iTunes) from my PC to my new iMac?
    Thank you so much for any help!

    Hello! I'd like to learn more about Home Sharing. To do this, would both my PC (which I hope to get rid of) and my new iMac need to be plugged in?
    Also, after Home Sharing with the old PC is initiated, I understand that all my songs would appear on my iMac. Is there a way to copy all of these (with album artwork, name, artist, etc.) directly to the iMac's hard drive and then disconnect home sharing so I can get rid of my PC?
    Thank you!

  • How to use PDF files with links to other PDF Files

    How to use a PDF file with links to other PDF files that have been transferred to the same folder

    Are you using a mouse, or a trackpad on a laptop? Either way, your cursor is usually an arrow, right? And presumably it's working/moving MOST of the time, otherwise you wouldn't be able to do anything?
    For example, can you move the cursor arrow to the "Annotate" tool to click on it and go into Annotate mode? If so, can you click on the text tool? If so, does the cursor change to a crosshairs? At what point can you NOT move the cursor around the screen?
    Matt

  • How to read metadata from a pdf file

    hello
    i have got xmp sdk for windows.
    i want to read the metadata from a pdf file but i cannot
    find a way to do so.
    i cannot understand that which method to use to open the file whose metadata i want to read.
    if someone can tell me by an little code example then it would be great help.
    thanks

    The sample XAPDumper read metadata in a file (PDF or not) if it is valide. If you want to keep the XAPMeta object, don't delete this object in ProcessSubstring().

  • Metadata from CDs to files

    Ripping a CD with Metadata from FREEDB seems to work.
    How does one get this data into the saved file in BWF & Cart Chunk, to use with radio automation? Is there a step by step process? I can not seem to get it to work, except of retyping it in, which defeats the purpose.

    I believe you have to choose the option, "Write changes to XMP" to have that happen. For those files that you have already added the information, try highlighting them and pressing Ctrl(Cmd)/S.

  • Importing RAW files with keywords from Bridge

    Hi everyone,
    I downloaded the trial version of Aperture and have now imported RAW files (Canon 20D) with keywords and IPTC data applied via Bridge.
    The import of the RAW files was no problem however the files lacked the keywords and IPTC data, which I applied in Bridge.
    I also tried to import JEPG files and here Aperture could show me keywords and IPTC data.
    Why does this not work for RAW files? What do I have to do in order to get it to work?
    Thanks in advance for your advise
    /David

    When you add metadata (keywords etc.) to most proprietary raw formats (including Canon .CR2 files), Bridge doesn’t know how to embed that data in to the file—Canon and other manufacturers haven’t told Adobe (or anyone else) what the structure of these raw files is and how metadata can be stored within the file itself. Therefore, Bridge creates a ‘sidecar’ file to go with the raw file: the sidecar file sits alongside the raw file, with the same filename and a .xmp extension. This sidecar file contains any metadata you may have applied, as well as adjustments you have made in Adobe Camera Raw.
    Unfortunately, Aperture doesn’t read these sidecar files when importing raw files, so you lose any adjustments from ACR (not surprising, since Aperture is obviously a different raw converter to ACR so the adjustments would be different anwyay), but also you lose any metadata you may carefully have applied.
    There may be an answer, however. But it’ll cost. That would be to use iView Media Pro (which has recently been bought by Microsoft, but a Mac version still exists). There is a 21-day free trial for iVMP—since my suggestion is to use it as a temporary conduit for importing all your existing raw files into Aperture, you won’t necessarily have to pay the £129 GBP asking price for iVMP (others can debate the morality of that statement, however; fortunately I already owned iVMP and so didn’t have to worry about such things). I believe iVMP can read the XMP sidecar files created by Bridge. Create a new iVMP catalogue with all your raw files which you want to move into Aperture. It should bring all your existing metadata into the iVMP catalogue as well.
    Then, import all the raw files into Aperture. As you have found, they’ll be without any metadata. As long as the filenames are the same in both the iVMP catalogue and the Aperture library, you can use Adam Tow’s application Annoture to transfer metadata from the iVMP catalogue into the Aperture library.
    Sort of circuitous, but possible. If only Aperture read the metadata from those sidecar files, eh? If I’m wrong in thinking that iVMP imports the XMP metadata, then what you can do is get Bridge to convert all your .CR2 raw files into .DNG files. If you don’t know about DNG, read about it at Adobe. But briefly, Bridge is able to embed its metadata into the DNG files and iVMP is able to read that embedded metadata when importing DNG files into the catalogue. I know that for certain: I used iVMP and DNG files (from my own 20D) before using Aperture; when I started using Aperture (which I love, now) I used Annoture to transfer all my metadata from iVMP into Aperture.
    Perhaps someone else will explain this better than I.

  • Looking for help for sharing pdf files with ipad from mac.  Pages only recognizes text.  What app should I use for file sharing pdf documents?

    Looking for advice on how to share pdf files with iPad from Mac.   Pages seems to only recognize text.   What app is recommended for pdf documents?

    Welcome to Apple Support Communities!
    If I understand your question, you want to read pdfs on your iPad, not create or edit.
    Drag pdf files to the iPad icon in Finder while connected to your computer via the USB cable.
    They will show up in the iBooks application
    (If you don't already have iBooks, it's a free download from the App Store.)
    Once installed, there are two buttons at the top left of the Bookshelf.
    One is Books, the other is Collections.
    Tap Collections, and you'll see Books and PDFs.
    Tap PDFs and you're there.

  • Create xml file with values from context

    Hi experts!
    I am trying to implement a WD application that will have some input fields, the value of those input fields will be used to create an xml file with a certain format and then sent to a certain application.
    Apart from this i want to read an xml file back from the application and then fill some other context nodes with values from the xml file.
    Is there any standard used code to do this??
    If not how can i do this???
    Thanx in advance!!!
    P.S. Points will be rewarded to all usefull answers.
    Edited by: Armin Reichert on Jun 30, 2008 6:12 PM
    Please stop this P.S. nonsense!

    Hi,
    you need to create three util class for that:-
    XMLHandler
    XMLParser
    XMLBuilder
    for example in my XML two tag item will be there e.g. Title and Organizer,and from ur WebDynpro view you need to pass value for the XML tag.
    And u need to call buildXML()function of builder class to generate XML, in that i have passed bean object to get the values of tags. you need to set the value in bean from the view ui context.
    Code for XMLBuilder:-
    Created on Apr 4, 2006
    Author-Anish
    This class is to created for having function for to build XML
    and to get EncodedXML
      and to get formated date
    package com.idb.events.util;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import com.idb.events.Event;
    public class XMLBuilder {
    This attribute represents the XML version
         private static final double VERSION_NUMBER = 1.0;
    This attribute represents the encoding
         private static final String ENCODING_TYPE = "UTF-16";
         /*Begin of Function to buildXML
    return: String
    input: Event
         public String buildXML(Event event) {
              StringBuffer xmlBuilder = new StringBuffer("<?xml version=\"");
              xmlBuilder.append(VERSION_NUMBER);
              xmlBuilder.append("\" encoding=\"");
              xmlBuilder.append(ENCODING_TYPE);
              xmlBuilder.append("\" ?>");
              xmlBuilder.append("<event>");
              xmlBuilder.append(getEncodedXML(event.getTitle(), "title"));
              xmlBuilder.append(getEncodedXML(event.getOrganizer(), "organizer"));
              xmlBuilder.append("</event>");
              return xmlBuilder.toString();
         /End of Function to buildXML/
         /*Begin of Function to get EncodedXML
    return: String
    input: String,String
         public String getEncodedXML(String xmlString, String tag) {
              StringBuffer begin = new StringBuffer("");
              if ((tag != null) || (!tag.equalsIgnoreCase("null"))) {
                   begin.append("<").append(tag).append(">");
                   begin.append("<![CDATA[");
                   begin.append(xmlString).append("]]>").append("</").append(
                        tag).append(
                        ">");
              return begin.toString();
         /End of Function to get EncodedXML/
         /*Begin of Function to get formated date
    return: String
    input: Date
         private final String formatDate(Date inputDateStr) {
              String date;
              try {
                   SimpleDateFormat simpleDateFormat =
                        new SimpleDateFormat("yyyy-MM-dd");
                   date = simpleDateFormat.format(inputDateStr);
              } catch (Exception e) {
                   return "";
              return date;
         /End of Function to get formated date/
    Code for XMLParser:-
    Created on Apr 12, 2006
    Author-Anish
    This is a parser class
    package com.idb.events.util;
    import java.io.ByteArrayInputStream;
    import java.io.IOException;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    import org.xml.sax.XMLReader;
    import com.idb.events.Event;
    import com.sap.tc.webdynpro.progmodel.api.IWDMessageManager;
    public class XMLParser {
    Enables namespace functionality in parser
         private final boolean isNameSpaceAware = true;
    Enables validation in parser
         private final boolean isValidating = true;
    The SAX parser used to parse the xml
         private SAXParser parser;
    The XML reader used by the SAX parser
         private XMLReader reader;
    This method creates the parser to parse the user details xml.
         private void createParser()
              throws SAXException, ParserConfigurationException {
              // Create a JAXP SAXParserFactory and configure it
              SAXParserFactory saxFactory = SAXParserFactory.newInstance();
              saxFactory.setNamespaceAware(isNameSpaceAware);
              saxFactory.setValidating(isValidating);
              // Create a JAXP SAXParser
              parser = saxFactory.newSAXParser();
              // Get the encapsulated SAX XMLReader
              reader = parser.getXMLReader();
              // Set the ErrorHandler
    This method is used to collect the user details.
         public Event getEvent(
              String newsXML,
              XMLHandler xmlHandler,
              IWDMessageManager mgr)
              throws SAXException, ParserConfigurationException, IOException {
              //create the parser, if not already done
              if (parser == null) {
                   this.createParser();
              //set the parser handler to extract the
              reader.setErrorHandler(xmlHandler);
              reader.setContentHandler(xmlHandler);
              InputSource source =
                   new InputSource(new ByteArrayInputStream(newsXML.getBytes()));
              reader.parse(source);
              //return the results of the parse           
              return xmlHandler.getEvent(mgr);
    Code for XMLHandler:-
    Created on Apr 12, 2006
    Author-Anish
    This is a parser class
    package com.idb.events.util;
    import java.io.ByteArrayInputStream;
    import java.io.IOException;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    import org.xml.sax.XMLReader;
    import com.idb.events.Event;
    Created on Apr 12, 2006
    Author-Anish
    *This handler class is created to have constant value for variables and function for get events,
        character values for bean variable,
        parsing thr date ......etc
    package com.idb.events.util;
    import java.sql.Timestamp;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.Locale;
    import org.xml.sax.Attributes;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    import org.xml.sax.helpers.DefaultHandler;
    import java.util.*;
    import com.idb.events.Event;
    import com.sap.tc.webdynpro.progmodel.api.IWDMessageManager;
    public class XMLHandler extends DefaultHandler {
         private static final String TITLE = "title";
         private static final String ORGANIZER = "organizer";
         IWDMessageManager manager;
         private Event events;
         private String tagName;
         public void setManager(IWDMessageManager mgr) {
              manager = mgr;
    This function is created to get events
         public Event getEvent(IWDMessageManager mgr) {
              manager = mgr;
              return this.events;
    This function is created to get character for setting values through event's bean setter method
         public void characters(char[] charArray, int startVal, int length)
              throws SAXException {
              String tagValue = new String(charArray, startVal, length);
              if (TITLE.equals(this.tagName)) {
                   this.events.setTitle(tagValue);
              if (ORGANIZER.equals(this.tagName)) {
                   String orgName = tagValue;
                   try {
                        orgName = getOrgName(orgName);
                   } catch (Exception ex) {
                   this.events.setOrganizer(orgName);
    This function is created to parse boolean.
         private final boolean parseBoolean(String inputBooleanStr) {
              boolean b;
              if (inputBooleanStr.equals("true")) {
                   b = true;
              } else {
                   b = false;
              return b;
    This function is used to call the super constructor.
         public void endElement(String uri, String localName, String qName)
              throws SAXException {
              super.endElement(uri, localName, qName);
         /* (non-Javadoc)
    @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
    This function is used to call the super constructor.
         public void fatalError(SAXParseException e) throws SAXException {
              super.fatalError(e);
    This function is created to set the elements base on the tag name.
         public void startElement(
              String uri,
              String localName,
              String qName,
              Attributes attributes)
              throws SAXException {
              this.tagName = localName;
              if (ROOT.equals(tagName)) {
                   this.events = new Event();
         public static void main(String a[]) {
              String cntry = "Nigeria";
              XMLHandler xml = new XMLHandler();
              ArrayList engList = new ArrayList();
              engList = xml.getCountries();
              ArrayList arList = xml.getArabicCountries();
              int engIndex = engList.indexOf(cntry);
              System.out.println("engIndex  :: " + engIndex);
              String arCntryName = (String) arList.get(engIndex);
              System.out.println(
                   ">>>>>>>>>>>>>>>>>>>>" + xml.getArabicCountryName(cntry));
    Hope that may help you.
    If need any help , you are most welcome.
    Regards,
    Deepak

  • Serving up files with Russian chars in the file name

    Anyone know how to get CF 8 to serve up CFM files with
    Russian characters in the file name? I can get IIS to server up
    .html files but .cfm files turn in to ?????????.cfm files.
    For example, this:
    новостииобновления.cfm
    becomes this ??????????????.cfm and throws a CF error (File Not
    Found) when clicking on the link. The strange thing is I can see
    the Russian characters in the status bar when I mouse over the link
    but CF can't handle it. And IIS will serve up the file and replace
    all the chars with their URL entity equivalent.
    Any suggestions on how to fix?

    Open the Script Editor or AppleScript Editor in one of the subfolders of Applications and run the following:
    tell application "Finder" to quit
    if (do shell script "defaults read com.apple.finder AppleShowAllFiles") is "1" then
    do shell script "defaults write com.apple.finder AppleShowAllFiles 0"
    else
    do shell script "defaults write com.apple.finder AppleShowAllFiles 1"
    end if
    delay 2
    tell application "Finder" to run
    If you change your mind later, run the script again.
    (93787)

  • Looking for pure Java API to read metadata from an MP4 file.

    Hi, I am looking for a pure Java api that can read MP4 metadata. I have been trying to look online for one but have not found anything
    suitable. If there are no good api's, can someone point me to resources on how to parse metadata from an MP4, tutorials would be great
    as well. I have looked online for that as well but have not found much. Any help would be greatly appreciated.

    Cross posted
    http://www.java-forums.org/new-java/59652-looking-pure-java-api-read-metadata-mp4-file.html
    http://www.coderanch.com/t/580833/Streams/java/Looking-pure-Java-API-read
    http://stackoverflow.com/questions/10568588/looking-for-pure-java-api-to-read-metadata-from-an-mp4-file
    db

  • How can i get the all values from the Property file to Hashtable?

    how can i get the all values from the Property file to Hashtable?
    ok,consider my property file name is pro.PROPERTIES
    and it contain
    8326=sun developer
    4306=sun java developer
    3943=java developer
    how can i get the all keys & values from the pro.PROPERTIES to hashtable
    plz help guys..............

    The Properties class is already a subclass of Hashtable. So if you have a Properties object, you already have a Hashtable. So all you need to do is the first part of that:Properties props = new Properties();
    InputStream is = new FileInputStream("tivoli.properties");
    props.load(is);

  • How do you move itunes with playlists from one computer to another

    how do you move itunes with playlists from a computer to ext hard drive, so it will play from the ext harddrive and not the computer

    Type "move itunes library to external hard drive" into the google search bar.

  • How to read a tab seperated data from a text file using utl_file

    Hi,
    How to read a tab seperated data from a text file using utl_file...
    I know if we use UTL_FILE.get_line we can read the whole line...but i need to read the tab separated value separately.....
    Thanks in advance...
    Naveen

    Naveen Nishad wrote:
    How to read a tab seperated data from a text file using utl_file...
    I know if we use UTL_FILE.get_line we can read the whole line...but i need to read the tab separated value separately.....If it's a text file then UTL_FILE will only allow you to read it a line at a time. It is then up to you to split that string up (search for split string on this forum for methods) into it's individual components.
    If the text file contains a standard structure on each line, i.e. it is a fixed delimited structure, then you could use external tables to read the data instead.

Maybe you are looking for